
DigitalOcean에서 무료로 $ 100 크레딧을 받으십시오.
불화에 가입하십시오 :
Metawrite는 Svelte / SvelteKit 에 대한 구성 요소를 준비하는 appwrite sdk입니다.
이 패키지는 alsicio에 의해 유지됩니다.
참고 :
xxn버전은 패키지 문서 또는 타이핑의 약간의 변경을 의미합니다.
xnx버전에는 약간의 중단 변경이 포함될 수 있습니다. 릴리스 노트를 참조하십시오.
nxx버전에는 몇 가지 주요 중단 변경이 포함될 수 있습니다. 릴리스 노트를 참조하십시오.
패키지는 AppWrite Server 0.12, Web SDK 6 및 Sveltekit과 완전히 작동하며 호환됩니다. 그러나 사람들은 현재 npm install metawrite 에 어려움을 겪고 있습니다. Metawrite를 사용하고 여기에 설명 된 것처럼 Docker 이미지로도 사용할 수있는 Sveltekit 템플릿을 준비하고 구성했습니다.
템플릿 사용을 고려하십시오. 이것은 일시적입니다
NPM 사용 :
npm install metawrite원사 사용 :
yarn add metawrite<User /><Create /><Preferences /><RecoverPassword /><Update /><Verification /><AuthEmail /><AuthOAuth2 /><CreateAnonymousSession /><CreateJWT /><MagicURL /><Browser /><CreditCard /><Favicon /><Flag /><Image /><QR /><Collection /><Document /><Storage /><FileList /><File /><Function /><Continents /><Countries /><Currencies /><Languages /><Locale /><PhoneCodes />이 라이브러리를 사용하려면 appwrite의 실행중인 인스턴스가 필요합니다. 더 많은 지침을 보려면 https://appwrite.io/docs/installation으로 이동하십시오.
psuedo 예
여러 수준의 비동기 관계 데이터 (및 하중 및 폴백 상태)를 전적으로 벨트 마크 업으로 처리합니다.
<!-- 1. ? Appwrite App -->
< Appwrite {... config }>
<!-- 2. ? Get the current user if logged in -->
< User let:user >
< h1 >Hello { user . name }!</ h1 >
<!-- 3. Get all the documents from a collection -->
< Collection collectionId = " 5f56a3035a01f " let:documents >
You have { documents . length } documents.
{ #each documents as document }
<!-- 4. Get a document -->
< Document collectionId = "5f56a3035a01f" documentId ={ document . $id } { document }>
Title: { document . title }
Text: { document . text }
... 초기화하고 모든 metawrite 구성 요소를 랩핑해야합니다.
< script >
import { Appwrite } from ' metawrite ' ;
const config = {
endpoint : ' http://localhost/v1 ' ,
project : ' demo ' ,
locale : ' fr '
};
</ script >
< Appwrite {... config }>...</ Appwrite >| 이름 | 설명 |
|---|---|
endpoint | appwrite endpoint. @type - {string} |
project | 프로젝트 ID. @type - {string} |
locale | 선택 사양 사용자 로케일. @type - {string} |
realtime | 선택 사양 설정 사용자 정의 실시간 엔드 포인트. 기본적으로 endpoint 와 동일합니다. @type - {string} |
새 계정을 등록합니다.
< script >
import { Create } from ' metawrite ' ;
let email = ' ' ;
let password = ' ' ;
let name = ' ' ;
const success = ( e ) => {
// success callback
// `e` contains the user object
};
const failure = ( e ) => {
// failure callback
};
</ script >
< Create let:actions on:success on:failure >
< input type = "text" bind:value ={ email } />
< input type = "password" bind:value ={ password } />
< input type = "text" bind:value ={ name } />
< button on:click ={ actions . create ( email , password , name )}>Register</ button >
</ Create > 하자 : 액션 object
기능이있는 객체.
| 이름 | 설명 |
|---|---|
create(email, password, name) | 새 사용자를 등록합니다. @type - {string} |
on : 성공
성공적인 레지스터를 트리거합니다.
| 이름 | 설명 |
|---|---|
response | 응답 |
on : 실패
실패 레지스터를 트리거합니다.
| 이름 | 설명 |
|---|---|
response | 응답 |
이메일 및 비밀번호를 통해 로그인하십시오.
< script >
import { AuthEmail } from ' metawrite ' ;
let email = ' ' ;
let password = ' ' ;
const success = ( e ) => {
// success callback
// `e` contains the user object
};
const failure = ( e ) => {
// failure callback
};
</ script >
< AuthEmail let:authorize on:success on:failure >
< input type = "text" bind:value ={ email } />
< input type = "text" bind:value ={ password } />
< button on:click ={ authorize ( email , password )}>Login</ button >
</ AuthEmail > 하자 : function 승인하십시오
로그인을 시작합니다.
| 이름 | 설명 |
|---|---|
email | 이메일. @type - {string} |
password | 비밀번호. @type - {string} |
on : 성공
성공적인 로그인을 트리거합니다.
| 이름 | 설명 |
|---|---|
email | 이메일. @type - {string} |
on : 실패
로그인 실패로 트리거합니다.
| 이름 | 설명 |
|---|---|
error | 오류 객체. |
OAUTH2 제공 업체를 통해 로그인하십시오.
< script >
import { AuthOAuth2 } from ' metawrite ' ;
</ script >
< AuthOAuth2
authProvider = " google "
success = " http://localhost:3000?success "
failure = " http://localhost:3000?failure "
let:authorize
>
< button on:click ={ authorize }>Login Google</ button >
</ AuthOAuth2 >| 이름 | 설명 |
|---|---|
authProvider | OAUTH2 공급자. @type - {string} |
success | 성공 URL. @type - {string} |
failure | 실패 URL. @type - {string} |
하자 : function 승인하십시오
현재 사용자에게 로그인 된 지 확인하도록 요청합니다.
< script >
import { User } from ' metawrite ' ;
</ script >
< User let:user >
< h1 >Hello { user . name }!</ h1 >
< div >{ user . email }</ div >
< div slot = " error " >You are not logged in!</ div >
</ User > 하자 : 사용자 object
현재 로그인 한 사용자 데이터를 얻으십시오.
컬렉션에서 모든 문서 목록을 받으십시오.
< script >
import { Collection } from ' metawrite ' ;
</ script >
< Collection collectionId = " 5f56a3035a01f " let:documents >
You have { documents . length } documents.
</ Collection >| 이름 | 설명 |
|---|---|
collectionId | 컬렉션 고유 ID. @type - {string} |
| 추가의 | 여기와 동일합니다 |
하자 : 문서 array
문서 배열.
하자 : 액션 object
기능이있는 객체.
| 이름 | 설명 |
|---|---|
reload() | 다시 가져 오기 컬렉션. |
create(data, read, write) | 컬렉션에서 새 문서를 만듭니다. read / write 선택 사항이며 기본적으로 @type - {string[]} 로 현재 사용자입니다. data 는 @type - {string} 입니다. |
문서를 받으십시오. 데이터로 document 속성을 전달하면 요청 된 데이터가 없습니다.
< script >
import { Document } from ' metawrite ' ;
</ script >
< Document documentId = " 5f56a3asda01f " let:document >
Title: { document . title }
Text: { document . text }
</ Document >| 이름 | 설명 |
|---|---|
documentId | 고유 한 ID를 문서화하십시오. @type - {string} |
collectionId | 컬렉션 고유 ID. @type - {string} |
| 또는 | |
document | <Collection /> 에서 전달 된 문서 |
하자 : 문서 object
문서 데이터가있는 JSON 객체.
하자 : 액션 object
기능이있는 객체.
| 이름 | 설명 |
|---|---|
update(data) | 문서를 업데이트하십시오. data 는 @type - {string} 입니다. |
remove() | 문서를 삭제합니다. |
reload() | 문서를 다시 가져 오십시오. |
on : 변경
로그인 업데이트 또는 제거를 트리거합니다.
계정 구성 요소를 사용하면 사용자 계정을 관리 할 수 있습니다.
<User /> 하자 : 행동
| 이름 | 설명 |
|---|---|
reload() | 새로 고침. |
logout() | 로그 아웃 현재 세션. |
logoutAll() | 모든 세션에서 로그 아웃. |
logoutFrom(session) | 특정 세션에서 로그 아웃. session @type - {string} 입니다. |
objectlogout 성공에 대한 성공을 누르십시오.logout 실패에 대한 Failurelogout.logoutFrom 습니다.logoutFrom 으로 인한 Failurelogoutfrom.logoutAll 성공에 대한 SuccessLogoutAll.logoutAll 고장에 대한 Failurelogoutall. < script >
import { User } from ' metawrite ' ;
</ script >
< User let:actions let:user >
< button on:click ={ actions . reload ()}>Reload user data</ button >
< button on:click ={ actions . get ()}>Get logged in user data</ button >
< button on:click ={ actions . logout ()}>Log out from current session</ button >
< button on:click ={ actions . logoutFrom ( ' sessionId ' )}>Log out from specific session</ button >
< button on:click ={ actions . logoutAll ()}>Log out from all sessions</ button >
<!-- If logged in -->
< p >Hi, { user . name }</ p >
</ User ><Create /> 하자 : 행동
| 이름 | 설명 |
|---|---|
create(email, password, name) | 사용자를 만듭니다. email 과 password 가 필요합니다 - @type - {string} . name 은 선택 사항 - @type - {string} |
createcreate 에 실패. < script >
import { Create } from ' metawrite ' ;
let name,
email,
password = ' ' ;
const success = ( e ) => {
// success callback
// `e` contains the user object
};
const failure = ( e ) => {
// failure callback
};
</ script >
< Create let:actions on:success on:failure >
< input type = "text" name = "name" placeholder = "name" bind:value ={ name } />
< input type = "text" name = "email" placeholder = "email" bind:value ={ email } />
< input type = "password" name = "password" placeholder = "password" bind:value ={ password } />
< button on:click ={ actions . create ( name , email , password )}>Create Account</ button >
</ Create ><Preferences /> 하자 : 행동
| 이름 | 설명 |
|---|---|
reload() | 기본 설정을 다시로드합니다. |
update(prefs) | 기본 설정 업데이트. prefs @type - {object} |
reload Success의 성공.reload 고장의 고장.update 성공에 대한 성공.update . < script >
import { Preferences } from ' metawrite ' ;
let prefs = {
// You can pass only the specific settings you wish to update.
};
</ script >
< Preferences let:actions >
< button
on:click ={() => {
actions . update ( prefs );
actions . reload ();
}}>Update Preferences</ button
>
</ Preferences ><RecoverPassword /> 하자 : 행동
| 이름 | 설명 |
|---|---|
recover(email, url) | 비밀번호 복구. email 및 url 이 필요하며 @type - {string} 필요합니다. url complete 기능으로 secret 처리 할 페이지입니다. |
complete(user, secret, password, passwordAgain) | 비밀번호 복구를 완료하십시오. user 와 secret metawrite 에 의해 자동으로 설정되므로 설정할 필요가 없습니다. password 및 passwordAgain 이 필요합니다 - @type - {string} . |
reload Success에서 AcrctRecover.reload Failupdate 성공에 성공적으로 성공합니다.update 실패시 FAILERECELLETE. < script >
import { RecoverPassword } from " metawrite " ;
const url = " http://localhost:3000/reset-password " ; // URL that will point to the next step.
let email = ' ' ;
const successRecover = e => {
// success callback
// `e` contains the user object
};
const failureRecover = e => {
// failure callback
}
</ script >
<!-- localhost/forgot-password -->
< RecoverPassword let:actions on:successRecover on:failureRecover >
< input name = "email" type = "text" bind:value ={ email , url } placeholder = " Email " />
< button on:click { actions . recover ( email )}>Recover Password</ button >
</ RecoverPassword >
<!-- Then on localhost/reset-password -->
< script >
import { RecoverPassword } from " metawrite " ;
let password, passwordAgain = ' ' ;
const successComplete = e => {
// success callback
// `e` contains the user object
};
const failureComplete = e => {
// failure callback
}
</ script >
< RecoverPassword let:actions on:successComplete on:failureComplete >
< input type = "password" name = "password" bind:value { password } placeholder = " Password " />
< input type = "password" name = "password" bind:value { passwordAgain } placeholder = " Confirm Password " />
< button on:click { actions . complete ( password , passwordAgain )}>Set New Password</ button >
</ RecoverPassword ><Update /> 하자 : 행동
| 이름 | 설명 |
|---|---|
name(name) | 업데이트 이름. 모든 필드가 필요합니다. @type - {string} |
email(email, password) | 이메일 업데이트. 모든 필드가 필요합니다. @type - {string} |
password(password, oldPassword) | 비밀번호 업데이트. 모든 필드가 필요합니다. @type - {string} |
name .name 실패에 대한 FailureName.email 성공에 대한 성공 메일.email 실패에 대한 실패 메일.password 성공에 대한 SuccessPassword.password . < script >
import { Update } from ' metawrite ' ;
let name,
email,
password,
newPassword,
oldPassword = ' ' ;
</ script >
< Update let:actions >
< button on:click ={ actions . name ( name )}>This updates name</ button >
< button on:click ={ actions . email ( email , password )}>This updates email</ button >
< button on:click ={ actions . password ( newPassword , oldPassword )}>This updates password</ button >
</ Update ><Verification />사용자 이메일 확인을 생성하고 자동으로 확인합니다.
create 위한 유형 문자열의 url 앱이 호스팅되는 곳 또는 localhost 되어야합니다.update 작업의 경우 아무것도 전달할 필요가 없으며 프로세스가 자동화됩니다. 하자 : 행동
| 이름 | 설명 |
|---|---|
create(url) | 확인을 만듭니다. url 은 URL이 이메일받은 편지함으로 전송 된 확인 링크를 작성하는 데 사용한 것입니다. @type - {string} |
update(user, secret) | 완전한 검증. user 와 secret metawrite 에 의해 자동으로 설정됩니다. |
create 습니다.create 실패한 경우.complete 성공.complete 실패시 실패성. < script >
import { Verification } from ' metawrite ' ;
const url = window . location . href ;
</ script >
< Verification let:actions >
< button on:click ={ actions . create ( url )} />
< button on:click ={ actions . update ()}>Update email verification status</ button >
</ Verification >인증 구성 요소를 사용하면 사용자 계정을 인증 할 수 있습니다.
<AuthEmail /> authorize 의 성공.authorize 실패. < script >
import { AuthEmail } from ' metawrite ' ;
let email = ' ' ;
let password = ' ' ;
const success = ( e ) => {
// success callback
// `e` contains the user object
};
const failure = ( e ) => {
// failure callback
};
</ script >
< AuthEmail let:authorize on:success on:failure >
< input type = "text" bind:value ={ email } />
< input type = "text" bind:value ={ password } />
< button on:click ={ authorize ( email , password )}>Login</ button >
</ AuthEmail ><AuthOAuth2 /> | 이름 | 설명 |
|---|---|
authProvider | OAUTH2 공급자. @type - {string} |
success | 성공 URL. @type - {string} |
failure | 실패 URL. @type - {string} |
| #### 지시문 |
하자 : 승인 ()
< script >
import { AuthOAuth2 } from ' metawrite ' ;
</ script >
< AuthOAuth2
authProvider = " google "
success = " http://localhost:3000?success "
failure = " http://localhost:3000?failure "
let:authorize
>
< button on:click ={ authorize }>Login Google</ button >
</ AuthOAuth2 ><CreateAnonymousSession /> 하자 : 행동
| 이름 | 설명 |
|---|---|
create() | 익명 세션을 만듭니다. |
< script >
import { CreateAnonymousSession } from ' metawrite ' ;
</ script >
< CreateAnonymousSession let:actions >
< button on:click ={ actions . create }>Create Anonymous Session</ button >
</ CreateAnonymousSession ><CreateJWT />JWT 토큰을 만듭니다.
하자 : 행동
| 이름 | 설명 |
|---|---|
create() | JWT 토큰을 만듭니다. |
< script >
import { CreateJWT } from ' metawrite ' ;
</ script >
< CreateJWT let:actions >
< button on:click ={ actions . create }>Create JWT token</ button >
</ CreateJWT ><MagicURL /> 하자 : 행동
| 이름 | 설명 |
|---|---|
create(sessionId, email, url) | Magic URL 세션을 만듭니다. 이메일이 필요하고 URL은 완전한 단계 string 가리려면 sessionId 필요하지 않습니다. |
complete() | Magic URL 세션을 확인하고 완료합니다. |
< script >
import { MagicURL } from " metawrite " ;
let email = " "
const url = " http://localhost:3000/page-to-complete "
const successCreate = ( e ) => {
console . log (e)
}
const failureCreate = ( e ) => {
console . log (e)
}
const successComplete = ( e ) => {
console . log (e)
}
const failureComplete = ( e ) => {
console . log (e)
}
</ script >
< MagicURL let:actions on:successCreate on:successComplete on:failureCreate on:failureComplete >
< input type = "email" name = "email" placeholder = "Email" bind:value ={ email } />
< button on:click ={ actions . create ( email , url )}>Send login link</ button >
< button on:click ={ actions . complete ()}>Confirm Login</ button >
</ MagicURL >아바타 구성 요소는 앱 이미지, 아이콘 및 아바타와 관련된 일상적인 작업을 완료하는 데 도움이됩니다.
<Browser /> @type - {string}@type - {number}@type - {string}@type - {string} @type - {URL} < script >
import { Browser } from ' metawrite ' ;
</ script >
< Browser code = " firefox " let:src >
< img src ={ String ( src )} alt = " Browser " />
</ Browser ><CreditCard /> @type - {string}@type - {number}@type - {string}@type - {string} @type - {URL} < script >
import { CreditCard } from ' metawrite ' ;
</ script >
< CreditCard code = " amex " let:src >
< img src ={ String ( src )} alt = " card " />
</ CreditCard ><Favicon /> @type - {string} @type - {URL} < script >
import { Favicon } from ' metawrite ' ;
const url = window . location . href ;
</ script >
< Favicon { url } let:src >
< img src ={ String ( src )} alt = " favicon " />
</ Favicon ><Flag /> @type - {string}@type - {number}@type - {string}@type - {string} @type - {URL} < script >
import { Flag } from ' metawrite ' ;
</ script >
< Flag code = " canada " let:src >
< img src ={ String ( src )} alt = " flag " />
</ Flag ><Image /> @type - {string}@type - {number}@type - {number} @type - {URL} < script >
import { Image } from ' metawrite ' ;
let url = ' https://increas.io/ ' ;
let width,
height = 100 ;
</ script >
< Image { url } { width } { height } let:src >
< img src ={ String ( src )} alt = " someImage " />
</ Image ><QR /> @type - {string}@type - {optional}@type - {number}@type - {boolean} @type - {URL} < script >
import { QR } from ' metawrite ' ;
let text = ' https://increas.io/ ' ; // could be any text
let size = 500 ;
let margin = 1 ;
let download = false ;
</ script >
< QR { text } { size } { margin } { download } let:src >
< img src ={ String ( src )} alt = " QR Code " />
</ QR >데이터베이스 구성 요소를 사용하면 문서의 구조화 된 문서, 쿼리 및 필터 목록을 작성하고 고급 읽기 및 쓰기 액세스 권한을 관리 할 수 있습니다.
<Collection /> CollectionId- 필수 @type - {string}
캐시 - 선택 사항 , 기본적으로 false @type - {boolean} 으로 설정하십시오.
쿼리 : @type - {object}
쿼리 - 옵션 @type - {string[]}
옵션 @type - {number}
오프셋 - 옵션 @type - {number}
Cursor- 옵션 @type - {string}
Cursordirection- 옵션 @type - {string}
ORDERATTRIBUTES- 옵션 @type - {string[]}
OrderTypes- 옵션 @type - {string[]}
하자 : 행동
| 이름 | 설명 |
|---|---|
reload() | 새로 고침. |
create(documentId, data, read, write) | 문서를 만듭니다. data - @type - {string} .read / write 선택 사항 @type - {string[]} 입니다.documentId 선택 사항이며 기본적으로 고유 한 @type - {string} 생성합니다. |
< script >
import { Collection } from " metawrite " ;
</ script >
< Collection collectionId = " 5f56a3035a01f " let:documents >
You have { documents . length } documents.
</ Collection ><Document /> @type - {string}@type - {string} 하자 : 행동
| 이름 | 설명 |
|---|---|
reload() | 새로 고침. |
update(data) | 문서를 업데이트합니다. data - @type - {object} |
remove() | 문서를 제거합니다. |
< script >
import { Collection , Document } from ' metawrite ' ;
const collectionId = ' 5f56a3035a01f ' ;
</ script >
< Collection { collectionId } let:documents >
You have { documents . length } documents:
{ #each documents as document }
< Document { collectionId } documentId ={ document . $id } let:document let:actions >
Title: { document . title }
Text: { document . text }
< button on:click ={() => { actions . remove ()}}>Delete</ button >
</ Document >
{ /each }
</ Collection >AppWrite에서 실시간 사용에 대한 자세한 내용은 실시간 문서를 참조하십시오.
Realtime을 사용하면 구독 방법을 사용하여 서버 측의 모든 이벤트를 실시간으로들을 수 있습니다.
HTTP를 통해 새 데이터를 요청하는 대신 구독은 변경 될 때마다 새 데이터를 받게됩니다. 연결된 클라이언트는 WebSocket 연결을 통해 밀리 초 이내에 해당 업데이트를받습니다.
이를 통해 모든 AppWrite 서비스의 정보를 실시간으로 제공하여 대화식 및 반응 형 사용자 경험을 구축 할 수 있습니다.
string | string[] Let : Payload- 구독의 페이로드에는 다음 속성이 포함됩니다.
하자 : 행동
| 이름 | 설명 |
|---|---|
subscribe() | 하나 이상의 채널과 관련된 모든 업데이트를 구독합니다. |
unsubscribe() | 더 이상 구독에서 업데이트를받지 않으려면 콜백을 더 이상 호출하지 않도록 구독 취소 할 수 있습니다. |
< script >
import { Realtime } from ' metawrite ' ;
</ script >
< Realtime channels = " account " let:actions let:payload >
< h1 >{ payload . timestamp }</ h1 >
< button on:click ={ actions . subscribe ()}>Subscribe to Account channel</ button >
< button on:click ={ actions . unsubscribe ()}>Unsubscribe from Account channel</ button >
</ Realtime >스토리지 구성 요소를 사용하면 프로젝트 파일을 관리 할 수 있습니다. 모든 프로젝트 파일을 업로드,보기, 다운로드 및 쿼리 할 수 있습니다.
<Storage /> 하자 : 행동
| 이름 | 설명 |
|---|---|
create(bucketId, fileId, file, read, write) | 파일을 업로드합니다.fileId 가 필요합니다 @type - {string} , "unique()" 임의의 고유 ID를 생성하지만 사용자 정의를 사용할 수 있습니다.file 은 @type - {File} 이며 필요합니다.read / write 는 @type - {string[]} 이고 선택 사항입니다 |
< script lang = " ts " >
import { Storage } from " metawrite "
// Required
let bucketId = " default "
let file : File ;
let fileId = " unique() " ; // this will generate random unique id, but you can use custom
// Optional
let read : string [];
let write : string [];
</ script >
< Storage { file } let:actions >
< button on:click ={ actions . create ( bucketId , fileId , file , read , write )}>Upload File</ button >
</ Storage ><FileList /> @type - {string}@type - {string}@type - {number}@type - {number}@type - {string}@type - {string}@type - {string} => 쓰기 "ASC" 또는 "DESC" 하자 : 행동
| 이름 | 설명 |
|---|---|
reload() | 새로 고침. |
< script >
import { FileList } from " metawrite "
// Optional
let bucketId = ' default ' ;
let search = ' ' ;
let limit = 10 ;
let offset = 0 ;
let orderType = ' ASC ' ;
</ script >
< FileList { bucketId } { search } { limit } { offset } { orderType } let:actions let:files >
{ #each files as file }
< p >File: { file . name }</ p >
{ /each }
< button on:click ={ actions . reload ()}>Reload</ button >
</ FileList ><File /> @type - {string} 입니다.@type - {string} 입니다. 하자 : 행동
| 이름 | 설명 |
|---|---|
download() | 파일을 다운로드합니다. |
view() | 보기를 위해 파일을 가져옵니다. |
preview(width, height, quality, background, output) | 미리보기 파일을 가져옵니다. |
update(read, write) | 파일을 업데이트합니다. |
delete() | 파일을 삭제합니다. |
< script lang = " ts " >
import { File } from ' metawrite ' ;
// Required
let bucketId : string ;
let fileId : string ;
// OPTIONAL
/** @type {number} */ let width;
/** @type {number} */ let height;
/** @type {string} */ let gravity;
/** @type {number} */ let quality;
/** @type {number} */ let borderWidth;
/** @type {string} */ let borderColor;
/** @type {number} */ let borderRadius;
/** @type {number} */ let opacity;
/** @type {number} */ let rotation;
/** @type {string} */ let background;
/** @type {string} */ let output;
/** @type {string[]} */ let read;
/** @type {string[]} */ let write;
</ script >
< File { bucketId } { fileId } let:actions >
< button on:click ={ actions . download ()}>Download File</ button >
< button on:click ={ actions . view ()}>File View</ button >
< button on:click ={ actions . preview ()}>Preview File</ button >
< button on:click ={ actions . update ( read , write )}>Update File</ button >
< button on:click ={ actions . delete ()}>Delete File</ button >
</ File >Functions Service를 사용하면 지원되는 AppWrite 시스템 이벤트 또는 사전 정의 된 일정에 의해 트리거 될 수있는 사용자 정의 동작을 생성 할 수 있습니다.
AppWrite Cloud Functions를 사용하면 AppWrite에 의해 트리거되거나 사전 정의 된 일정으로 실행되도록 설정하여 자동으로 백엔드 코드를 실행할 수 있습니다. 코드는 AppWrite 인스턴스에 안전한 방식으로 저장되며 고립 된 환경에서 실행됩니다.
AppWrite의 Cloud Functions 튜토리얼을 따르면 자세한 내용을 배울 수 있습니다.
<Function /> 하자 : 행동
| 이름 | 설명 |
|---|---|
reload() | 새로 고침. |
create(functionId, data) | 실행을 만듭니다. functionId 필요하며 선택 사항 이므로 data 비어있을 수 있습니다. @type {string} |
create(functionId, executionId) | 실행을 받으십시오. 두 매개 변수 모두 필요합니다. @type {string} |
< script >
import { Function } from ' metawrite ' ;
let functionId = ' someExecution ' ; // required
let newFunctionId = ' ' ;
let data = ' String of custom data to send to function. ' ; // could be empty string because optional
</ script >
< Function { functionId } { data } let:actions let:executions >
{ #each executions as execution }
< p >
Execution ID: { execution . $id }, Function ID: { execution . functionId }, Date Created: { execution . dateCreated }
</ p >
{ /each }
< input type = "text" name = "functionId" placeholder = "Function ID" bind:value ={ newFunctionId } />
< button on:click ={ actions . create ( newFunctionId , data )}>Create Execution</ button >
</ Function >로케일 구성 요소를 사용하면 사용자의 위치에 따라 앱을 사용자 정의 할 수 있습니다.
<Continents /> 하자 : 행동
| 이름 | 설명 |
|---|---|
reload() | 새로 고침. |
< script >
import { Continents } from ' metawrite ' ;
</ script >
< Continents let:actions let:continents >
< button on:click ={ actions . reload ()}>Reload</ button >
< p >There are { continents . sum } continents:</ p >
{ #each continents . continents as continent }
< p >{ continent . name }, { continent . code }</ p >
{ /each }
</ Continents ><Countries /> 하자 : 행동
| 이름 | 설명 |
|---|---|
reload() | 새로 고침. |
< script >
import { Countries } from ' metawrite ' ;
let eu = true ; // if you want to list only EU countries
</ script >
< Countries let:actions let:countries >
< button on:click ={ actions . reload ()}>Reload</ button >
< p >There are { countries . sum } countries in the world:</ p >
{ #each countries . countries as country }
< p >{ country . name }, { country . code }</ p >
{ /each }
</ Countries >
< Countries { eu } let:actions let:countries >
< button on:click ={ actions . reload ()}>Reload</ button >
< p >There are { countries . sum } countries in EU:</ p >
{ #each countries . countries as country }
< p >{ country . name }, { country . code }</ p >
{ /each }
</ Countries ><Currencies /> 하자 : 행동
| 이름 | 설명 |
|---|---|
reload() | 새로 고침. |
< script >
import { Currencies } from ' metawrite ' ;
</ script >
< Currencies let:actions let:currencies >
< button on:click ={ actions . reload ()}>Reload</ button >
< p >There are { currencies . sum } currencies:</ p >
{ #each currencies . currencies as currency }
< p >{ currency . symbol } - { currency . name } ({ currency . code })</ p >
{ /each }
</ Currencies ><Languages /> 하자 : 행동
| 이름 | 설명 |
|---|---|
reload() | 새로 고침. |
< script >
import { Languages } from ' metawrite ' ;
</ script >
< Languages let:actions let:languages >
< button on:click ={ actions . reload ()}>Reload</ button >
< p >There are { languages . sum } languages:</ p >
{ #each languages . languages as language }
< p >{ language . name }, { language . code }></ p >
{ /each }
</ Languages ><Locale /> 하자 : 행동
| 이름 | 설명 |
|---|---|
reload() | 새로 고침. |
object < script >
import { Locale } from ' metawrite ' ;
</ script >
< Locale let:actions let:code >
< h1 >Active Session</ h1 >
< button on:click ={ actions . reload ()}>Reload</ button >
< p >Location: { code . country }, { code . continentCode }</ p >
< p >IP: { code . ip }</ p >
</ Locale ><PhoneCodes /> 하자 : 행동
| 이름 | 설명 |
|---|---|
reload() | 새로 고침. |
< script >
import { PhoneCodes } from ' metawrite ' ;
</ script >
< PhoneCodes let:actions let:codes >
< button on:click ={ actions . reload ()}>Reload</ button >
< p >There are { codes . sum } phone codes:</ p >
{ #each codes . phones as phone }
< p >{ phone . code } - { phone . countyName }></ p >
{ /each }
</ PhoneCodes >