You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great to add to the readme how to define models with BaseModel
my model is
export default class User extends BaseModel {
email: string
password: string
rememberMeToken: string | null
createdAt: Date
updatedAt: Date
status: StatusEnum = StatusEnum.Pending;
static async hashPassword(user: User) {
if (user.$dirty.password) {
user.password = await Hash.make(user.password)
}
}
static async isEmailTaken(email: string, excludeUserId) {
const user = await this.find({ email, _id: { $ne: excludeUserId } });
return !!user;
}
}
error thrown
err: {
"type": "MongoInvalidArgumentError",
"message": "Collection name must be a String",
"stack":
MongoInvalidArgumentError: Collection name must be a String
at checkCollectionName (/var/www/html/adonis/node_modules/mongodb/src/utils.ts:84:11)
at new Collection (/var/www/html/adonis/node_modules/mongodb/src/collection.ts:174:24)
at Db.collection (/var/www/html/adonis/node_modules/mongodb/src/db.ts:298:12)
at Connection.collection (/var/www/html/adonis/node_modules/@zakodium/adonis-mongodb/src/Database/Connection.ts:121:15)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at Function.find (/var/www/html/adonis/node_modules/@zakodium/adonis-mongodb/src/Model/Model.ts:406:24)
at Function.isEmailTaken (/var/www/html/adonis/app/Models/User.ts:53:18)
The text was updated successfully, but these errors were encountered:
Your definition of the user class seems correct and it runs without errors on my end if I replace this.find with this.query.
I suspect that you are using an old version of the package.
Hello Am getting this error
It would be great to add to the readme how to define models with BaseModel
my model is
error thrown
The text was updated successfully, but these errors were encountered: