How can I add programmatically a new element into an existing enum attribute that is not empty? I am using node sdk.
databases.updateEnumAttribute gives me this error "databases.updateEnumAttribute is not a function". Could this be a bug?
I am using appwrite cloud
@driver can you give whole code plz. It is difficult to help without more information
import { Client, Databases } from "node-appwrite";
export default async function handler(req, res) { const client = new Client(); client .setEndpoint(process.env.APPWRITE_ENDPOINT) .setProject(process.env.APPWRITE_PROJECT_ID) .setKey(process.env.APPWRITE_DATABASE_API_KEY);
const database = new Databases(client);
const databaseId = process.env.APPWRITE_DATABASE_ID_USERS; const collectionId = process.env.APPWRITE_DATABASE_COLLECTION_ID_POSITIONS; const data = req.body;
if (req.method === "POST") { try { console.log(data.categoryList); // ["Academic", "Technican", "Admin", "Test"] //test is a newly added enum by clinet const response = await database.updateEnumAttribute( databaseId, collectionId, "category", data.categoryList, true );
res.status(200).json(response); // nothing
} catch (error) {
console.log(error.message); // error database.updateEnumAttribute is not a function
res.status(500).json({ error: error.message });
}
} }
Tips : you can format your code with : https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline-#h_01GY0DAKGXDEHE263BCAYEGFJA
import { Client, Databases } from "node-appwrite";
export default async function handler(req, res) {
const client = new Client();
client
.setEndpoint(process.env.APPWRITE_ENDPOINT)
.setProject(process.env.APPWRITE_PROJECT_ID)
.setKey(process.env.APPWRITE_DATABASE_API_KEY);
const database = new Databases(client);
const databaseId = process.env.APPWRITE_DATABASE_ID_USERS;
const collectionId = process.env.APPWRITE_DATABASE_COLLECTION_ID_POSITIONS;
const data = req.body;
if (req.method === "POST") {
try {
console.log(data.categoryList); // ["Academic", "Technican", "Admin", "Test"] //test is a newly added enum by clinet
const response = await database.updateEnumAttribute(
databaseId,
collectionId,
"category",
data.categoryList,
true
);
res.status(200).json(response); // nothing
} catch (error) {
console.log(error.message); // error database.updateEnumAttribute is not a function
res.status(500).json({ error: error.message });
}
}
}
thanks, I am using nextjs
1.3 isn't already implemented on nodejs sdk, so you havn't all update endpoint, etc..
Check diff between
and
Okay, I see. Thanks
I think that's where it comes from. But prefer a confirmation from an appwrite staff @Steven
I suggest you to build your own rest or graphql client
That's what we did, to take advantage of the new features immediately
Thank you for the help @Bouahaza
do you have an idea when appwrite cloud will use the newer version?!
Not know, when beta closed ?
1.3 merged on master branch (https://github.com/appwrite/appwrite/pull/5432) So it should happen soon
Recommended threads
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...
- custom domain with CloudFlare
Hi all, it seems that CloudFlare has blocked cross-domain CNAME link which made my app hostname which is in CloudFlare, unable to create a CNAME pointing to clo...
- Type Mismatch in AppwriteException
There is a discrepancy in the TypeScript type definitions for AppwriteException. The response property is defined as a string in the type definitions, but in pr...