[SOLVED] how to create Attributes, reading the docs for Client and Server ?
- 0
- Resolved
- Databases
Quick question how to create Attributes for documents, reading the docs for Client and Server I can't find anything.
I want to set up database, collation and attributes from code, can anyone point me in the right direct.
https://appwrite.io/docs/references/cloud/server-nodejs/databases
This should have all the functions you're looking for.
Thanks, don't know how I missed that.
But do you have to do it one by one.
const promise = databases.createIpAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false);
and not a list of Attribute to process all at once?
It looks to be that way. I mean, I don't think it would be too terribly hard to create a function yourself that takes in something like an array of objects and creates those attributes from that?
async function createAttributes(attributes: Attributes) {
forEach(const attribute in attributes) {
switch(attribute.type) {
case "float":
await databases.createFloatAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false);
case "everything else"
await blah blah blah
}
}
}
Not sure if this is the best option but just something I quickly wrote rn.
Yep, going have to do that 🙂 Just making sure 100%
Thanks for help 🙂
No problem! :)
[SOLVED] how to create Attributes, reading the docs for Client and Server ?
Recommended threads
- I'm getting an error on the console "j?....
On my self hosted instance version 1.8.1 the console is giving me this error when trying to view the rows for a table I recently created. My application is read...
- Websites hosted on my appwrite sites hav...
Hello, all my websites hosted on appwrite sites are not running I am getting this message "This site can’t be reached drivehub.appwrite.network took too long t...
- Database Write Limits hit
Hello Appwrite Admins, I'm a GitHub Education user, and about a week ago, my database was really badly optimized, resulting in about 600k writes in a single day...