
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
- Having errors migrating to cloud
Project will not migrate compeltely
- 2 Columns still processing since yesterd...
Hey o/ Yesterday (around <t:1758045600:f>), I created a database and added several columns to it. After about 15 minutes, most of the "processing" tags disappe...
- 503 Timeout when Updating or Upserting D...
Hey I’m running into an issue when trying to update or upsert a row in Appwrite. The request hangs for a while and then throws this error: ``` AppwriteException...
