Skip to content

undownding/mongoose-autouid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongoose-autouid

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
}

About

Add an auto inc field named uid for schema.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published