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 issues with Goggle Authentication...
My google auth is not redirecting me to my failureurl. I think it might be a session issue because it's working in my laptop but when I try it in another laptop...
- coolify docs dont help installing latest...
coolify has older version of appwrite, how do i install latest version of appwrite
- I'm getting error Invalid `url` param: I...
``` 2025-10-26T12:52:02.292Z [error] AppwriteException: Invalid `url` param: Invalid URI. Register your new client (vercel.com) as a new Web platform on your pr...