Skip to content

Instantly share code, notes, and snippets.

@eldadfux
Created September 30, 2019 06:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eldadfux/0591d2205311b02966e5e365fbafad2a to your computer and use it in GitHub Desktop.
Save eldadfux/0591d2205311b02966e5e365fbafad2a to your computer and use it in GitHub Desktop.
Appwrite Database
let sdk = new Appwrite();
sdk
.setEndpoint('YOUR_SERVER_ENDPOINT') // http://localhost/v1
.setProject('YOUR_PROJECT_UID')
.setKey('YOUR_API_SECRET')
;
let promise = sdk.database.createCollection(
'Movies', // Collection Name
['*'], // Read permissions
['user:yyy', 'team:xxx'], // Write permissions
[ // Rules
{
"label": "Name",
"key": "name",
"type": "text",
"default": "",
"required": true,
"array": false
},
{
"label": "Release Year",
"key": "releaseYear",
"type": "numeric",
"default": 0,
"required": true,
"array": false
},
{
"label": "Notes",
"key": "notes",
"type": "text",
"default": 0,
"required": false,
"array": true
}
]
);
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment