
รับเครดิตฟรี $ 100 สำหรับ DigitalOcean:
เข้าร่วม Discord ของเรา:
MetawRite เป็น AppWrite SDK พร้อมส่วนประกอบพร้อมสำหรับ Svelte / SvelteKit
แพ็คเกจนี้ได้รับการบำรุงรักษาโดย uperio
หมายเหตุ: เวอร์ชัน
xxnหมายถึงการเปลี่ยนแปลงเล็กน้อยในเอกสารประกอบหรือการพิมพ์เวอร์ชัน
xnxอาจรวมถึงการเปลี่ยนแปลงเล็กน้อย ดูบันทึกย่อเวอร์ชัน
nxxอาจรวมถึงการเปลี่ยนแปลงที่สำคัญบางอย่าง ดูบันทึกย่อ
แพ็คเกจนี้ใช้งานได้อย่างสมบูรณ์และเข้ากันได้กับ AppWrite Server 0.12, Web SDK 6 และ SvelteKit แต่ผู้คนกำลังเผชิญกับปัญหากับ npm install metawrite เรามี เทมเพลต Sveltekit ที่พร้อมและกำหนดค่าที่ใช้ metawrite และสามารถใช้เป็นภาพนักเทียบท่าตามที่อธิบายไว้ที่นี่
โปรดพิจารณาใช้เทมเพลตนี่คือชั่วคราว
ใช้ 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
จัดการข้อมูลเชิงสัมพันธ์หลายระดับ (และสถานะการโหลดและทางเลือกของพวกเขา) ทั้งหมดจากมาร์กอัป SVELTE
<!-- 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 ของคุณ @type - {string} |
project | รหัสโครงการของคุณ @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} |
บน: ความสำเร็จ
ทริกเกอร์ในการลงทะเบียนที่ประสบความสำเร็จ
| ชื่อ | คำอธิบาย |
|---|---|
response | การตอบสนอง |
บน: ความล้มเหลว
ทริกเกอร์ในการลงทะเบียนที่ล้มเหลว
| ชื่อ | คำอธิบาย |
|---|---|
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} |
บน: ความสำเร็จ
ทริกเกอร์ในการเข้าสู่ระบบที่ประสบความสำเร็จ
| ชื่อ | คำอธิบาย |
|---|---|
email | อีเมล. @type - {string} |
บน: ความล้มเหลว
ทริกเกอร์ในการเข้าสู่ระบบที่ล้มเหลว
| ชื่อ | คำอธิบาย |
|---|---|
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() | เรียกร้องเอกสารอีกครั้ง |
บน: เปลี่ยน
ทริกเกอร์ในการอัปเดตหรือลบการเข้าสู่ระบบ
ส่วนประกอบบัญชีอนุญาตให้คุณจัดการบัญชีผู้ใช้
<User /> ให้: การกระทำ
| ชื่อ | คำอธิบาย |
|---|---|
reload() | โหลดใหม่ |
logout() | ออกจากระบบเซสชันปัจจุบัน |
logoutAll() | ออกจากระบบจากเซสชันทั้งหมด |
logoutFrom(session) | ออกจากระบบจากเซสชันเฉพาะ session คือ @type - {string} |
object ผู้ใช้logoutlogoutlogoutFrom ระบบlogoutFrom จากความล้มเหลวlogoutAlllogoutAll ล้มเหลว < 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} |
create ความสำเร็จcreate ความล้มเหลว < 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} |
reloadreload ความล้มเหลวupdateupdate < 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 คือหน้าของคุณที่คุณจะจัดการกับ secret ด้วยฟังก์ชั่น complete |
complete(user, secret, password, passwordAgain) | การกู้คืนรหัสผ่านที่สมบูรณ์ user และ secret ถูกตั้งค่าโดยอัตโนมัติโดย metawrite ดังนั้นคุณไม่จำเป็นต้องตั้งค่า จำเป็นต้องใช้ password และ passwordAgain - @type - {string} |
reloadreload ความล้มเหลวupdate ความสำเร็จupdate < 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 Successname ล้มเหลวemail Successemailpasswordpassword < 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 />สร้างและตรวจสอบการตรวจสอบอีเมลของผู้ใช้โดยอัตโนมัติ
url ของประเภทสตริงสำหรับการ create ควรเป็นที่ที่แอปของคุณโฮสต์หรือ localhostupdate คุณไม่จำเป็นต้องผ่านอะไรเลยกระบวนการนี้เป็นไปโดยอัตโนมัติ ให้: การกระทำ
| ชื่อ | คำอธิบาย |
|---|---|
create(url) | สร้างการยืนยัน url คือสิ่งที่ URL ที่ใช้ในการสร้างลิงค์การยืนยันที่ส่งไปยังกล่องจดหมายอีเมลของคุณ @type - {string} |
update(user, secret) | การยืนยันที่สมบูรณ์ user และ secret ถูกตั้งค่าโดยอัตโนมัติโดย metawrite |
create ความสำเร็จcreate ความล้มเหลวcompletecomplete < 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 >ส่วนประกอบ Auth ช่วยให้คุณสามารถตรวจสอบบัญชีผู้ใช้ได้
<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) | สร้างเซสชั่น URL เวทย์มนตร์ จำเป็นต้องใช้อีเมล URL คือการชี้ไปที่ string ขั้นตอนที่สมบูรณ์ไม่จำเป็นต้องใช้ sessionId |
complete() | ตรวจสอบและเสร็จสิ้นเซสชัน URL Magic |
< 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} เป็นตัวเลือก - {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 ตัวเลือก @type - {number}
ออฟเซ็ต - @type ตัวเลือก @type - {number}
เคอร์เซอร์ - @type เป็นตัวเลือก @type - {string}
Cursordirection - @type เป็นตัวเลือก @type - {string}
orderattributes - @type เป็นตัวเลือก @type - {string[]}
OrderTypes - @Type เป็นตัวเลือก @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 ดูเอกสารประกอบแบบเรียลไทม์
เรียลไทม์ช่วยให้คุณสามารถฟังเหตุการณ์ใด ๆ บนฝั่งเซิร์ฟเวอร์แบบเรียลไทม์โดยใช้วิธีการสมัครสมาชิก
แทนที่จะขอข้อมูลใหม่ผ่าน HTTP การสมัครสมาชิกจะได้รับข้อมูลใหม่ทุกครั้งที่มีการเปลี่ยนแปลงไคลเอนต์ที่เชื่อมต่อใด ๆ จะได้รับการอัปเดตนั้นภายในมิลลิวินาทีผ่านการเชื่อมต่อ WebSocket
สิ่งนี้ช่วยให้คุณสร้างประสบการณ์การใช้งานแบบโต้ตอบและตอบสนองได้โดยการให้ข้อมูลจากบริการทั้งหมดของ AppWrite แบบเรียลไทม์
string | string[] ให้: 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 >บริการฟังก์ชั่นช่วยให้คุณสามารถสร้างพฤติกรรมที่กำหนดเองที่สามารถเรียกใช้โดยเหตุการณ์ระบบ AppWrite ที่รองรับหรือตามกำหนดเวลาที่กำหนดไว้ล่วงหน้า
ฟังก์ชั่น AppWrite Cloud ช่วยให้คุณเรียกใช้รหัสแบ็กเอนด์โดยอัตโนมัติเพื่อตอบสนองต่อเหตุการณ์ที่ทริกเกอร์โดย AppWrite หรือโดยการตั้งค่าให้ดำเนินการในกำหนดการที่กำหนดไว้ล่วงหน้า รหัสของคุณถูกเก็บไว้อย่างปลอดภัยในอินสแตนซ์ AppWrite ของคุณและดำเนินการในสภาพแวดล้อมที่แยกได้
คุณสามารถเรียนรู้เพิ่มเติมได้โดยการสอนฟังก์ชั่นคลาวด์ของ AppWrite
<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 >