import conf from "@/conf/config";
import { Client, Databases, Account, ID } from "appwrite";
import appwriteService from "@/appwrite/config";
type createProject = {
name: string,
description: string,
logo: string,
url: string,
userId: string
}
const dbClient = new Client()
dbClient.setEndpoint(conf.appwriteUrl).setProject(conf.appwriteProjectId);
export const db = new Databases(dbClient)
export class dbService{
async createProject({name, description, logo, url, userId}: createProject) {
const account = new Account(dbClient);
const user = (await account.get()).$id
try {
const project = await db.createDocument(`${conf.appwriteDbId}`,`${conf.appwriteCollectionId}`, ID.unique(),{
name,
description,
logo,
url,
userId: user || ''
},[]
)
} catch (error:any) {
throw error
}
}
}
const dbServices = new dbService()
export default dbServices
While I try to create a document in the appwrite database. It should also save the userId who created the document. On this 15th line async createProject({name, description, logo, url, userId}: createProject
it shows that the 'userId' is declared but its value is never read. How do I fix this problem.