
async function createAdminClient() {
const client = new AppwriteClient();
client
.setEndpoint(process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT as string)
.setProject(process.env.NEXT_PUBLIC_PROJECT_ID as string)
.setKey(process.env.AUTH_SESSION_KEY as string);
return {
account: new Account(client),
users: new Users(client),
teams: new Teams(client),
functions: new Functions(client),
databases: new Databases(client),
};
};
const createAdminDB = async () => {
const { databases } = await createAdminClient();
const db = {} as DB;
collections.forEach((col: Collection) => {
db[col.name as keyof DB] = {
create: (payload: any, permissions: string[], id = ID.unique()) =>
databases.createDocument(
col.dbId,
col.id,
id,
payload,
permissions
),
update: (id: string, payload: any, permissions: string[]) =>
databases.updateDocument(
col.dbId,
col.id,
id,
payload,
permissions
),
delete: (id: string) => databases.deleteDocument(col.dbId, col.id, id),
list: (queries = []) =>
databases.listDocuments(col.dbId, col.id, queries),
get: (id: string) => databases.getDocument(col.dbId, col.id, id),
};
});
return db;
};
export { createAdminClient, createAdminDB};
and I have logic here to query some data
const db = await createAdminDB();
const promise: any = await db.clients.list([
Query.orderDesc("code"),
Query.limit(1),
]);
console.log(promise)
when I console log. it always get result which is not existed, as I already deleted

I try to restart terminal many times

also checking on the console web, there is no returned data here

I am trying to get the lastest code number from document , to increase it by 1
Recommended threads
- not getting cookie in header of appwrite...
my website working locally and on vercel , but when hosting on appwrite sites the main core issue is its not getting the cookie . <@743532656767270934> help
- custom domain failing
I have an appwrite app at a subdomain myapp.topdomain.com. I want to configure the appwrite endpoint to use a 2nd level subdomain e.g. api.myapp.topdomain.com. ...
- Appwrite Email Verification Query!!
Hi team I've created an Appwrite cloud function to send an email verification to a user. My understanding is that server-side code should use the Users API, bu...
