跳到主要内容
CNode

怎么使用mongolass驱动库连接mongodb数据库呀?

问答
Ddreamsline发布于 9 年前最后回复 9 年前
241190

exports.User = mongolass.model('User', { name: { type: 'string' }, password: { type: 'string' }, avatar: { type: 'string' }, gender: { type: 'string', enum: ['m', 'f', 'x'] }, bio: { type: 'string' } }); exports.User.index({ name: 1 }, { unique: true }).exec();// 根据用户名找到用户,用户名全局唯一 上面都是什么意思呀? 还有我不是太会mongolass,有没有比较好的资料学一下mongolass这个mongodb驱动库呀?

查看回复

回复 (2)

L
LukerSpringtree#29 年前

先学 mongoose 再用 mongolass

O
OneNewLife#19 年前

输出一个叫做 User 的数据模型,有 namepasswordavatargenderbio 等属性,将用户名设置为标志。

mongolass 没有文档,你只能看栗子和源码(很精简),要资料的话推荐你学 mongoose

参与回复

登录后即可参与回复。登录