Add an auto inc field named uid for schema.
usage:
import {AutoIncUid} from 'mongoose-autouid'
schema.plugin(AutoIncUid)
for NestJS:
MongooseModule.forFeatureAsync([
{
name: User.name,
useFactory: () => {
const schema = getSchema(User)
schema.plugin(AutoIncUid)
return schema
},
},
]),
in user.model.ts
@model('user', {timestamps: true})
export class User extends Model<User> implements IUserSchema {
...
@prop() @unique() public uid: number
}