Hi, what's the alternative way to hide specific keys? I've created a function, but I believe there might be another way to achieve this.
TypeScript
function secureSchema<T extends Record<string, any>>(doc: T): Omit<T, "$permissions" | "$databaseId" | "$collectionId"> {
const secureDoc: any = { ...doc };
function removeSecureProps(obj: any) {
for (const prop in obj) {
if (obj[prop] !== null && typeof obj[prop] === 'object') {
removeSecureProps(obj[prop]);
}
if (prop === '$permissions' || prop === '$databaseId' || prop === '$collectionId') {
delete obj[prop];
}
}
}
removeSecureProps(secureDoc);
return secureDoc;
}
//Services
async readAll(): Promise<VideoSchemaType[]> {
const documents = await database.listDocuments(dbId, videoCollectionId);
const data = documents.documents.map((doc: any) => secureSchema(doc)) as VideoSchemaType[];
return data;
}
TL;DR
Function `secureSchema` is used to hide specific keys in an object. An alternative way to achieve this without using the `secureSchema` function is by directly removing the desired keys from the object where necessary.Recommended threads
- total parameter not working correctly in...
Hello Appwrite team, I'm experiencing issues with the total parameter in the listRows() method (TablesDB) across multiple SDKs. **Issue 1**: Node.js SDK (node...
- rxdb integration code not working
https://appwrite.io/blog/post/offline-first-journal This code does not work with rxdb and appwrite packages set to february releases nor newest releases
- Costom domain Issues
Hi Appwrite team We’re having issues verifying a custom domain. We added the required CNAME and CAA records to our DNS provider and waited for at least 2 days a...