Board logo

標題: [操作疑難] 請問各位用開邊套 nodejs orm [打印本頁]

作者: gamezz    時間: 2021-12-23 18:04     標題: 請問各位用開邊套 nodejs orm

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

https://github.com/typeorm/typeorm
https://github.com/sequelize/sequelize/
https://github.com/prisma/prisma
作者: gamezz    時間: 2022-1-14 16:42

大家寫model時,會唔會將其他method寫入model入面?
例如user - generate hash key
定係應該開多個 user service file?
作者: kennyleunghk    時間: 2022-1-14 17:27

除了mongoose 外嘅ORM好似都唔太值得使用
如果要用ORM嘅話我會直接springboot
如果你一定要用node.js 行backend 玩ORM, sequelize 應該係最好嘅選擇啦
作者: superwebguys    時間: 2022-1-28 14:55

本帖最後由 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. };
複製代碼





歡迎光臨 電腦領域 HKEPC Hardware (https://h0.hkepc.com/forum/) Powered by Discuz! 7.2