[操作疑難] 請問各位用開邊套 nodejs orm

剛剛由 php codeigniter 轉用 nodejs,
請問各位用開邊套 orm? thanks.

https://github.com/typeorm/typeorm
https://github.com/sequelize/sequelize/
https://github.com/prisma/prisma

大家寫model時,會唔會將其他method寫入model入面?
例如user - generate hash key
定係應該開多個 user service file?

TOP

除了mongoose 外嘅ORM好似都唔太值得使用
如果要用ORM嘅話我會直接springboot
如果你一定要用node.js 行backend 玩ORM, sequelize 應該係最好嘅選擇啦

TOP

本帖最後由 superwebguys 於 2022-1-28 15:44 編輯

回覆 2# gamezz
網上有些example 把 password validation 放在user model 內:
  1. UsersSchema.methods.validatePassword = function(password) {
  2.   const hash = crypto.pbkdf2Sync(password, this.salt, 10000, 512, 'sha512').toString('hex');
  3.   return this.hash === hash;
  4. };
複製代碼

TOP