admin管理员组文章数量:1414908
I guess it's a stupid question but i would like do something like this
var mongoose = require('mongoose');
var Long = require("long");
var UserSchema = new mongoose.Schema({
id: Long(),
name: String,
pleted: Long(),
note: String,
updated_at: { type: Date, default: Date.now },
});
I guess it's a stupid question but i would like do something like this
var mongoose = require('mongoose');
var Long = require("long");
var UserSchema = new mongoose.Schema({
id: Long(),
name: String,
pleted: Long(),
note: String,
updated_at: { type: Date, default: Date.now },
});
But it's not working,"cannot set 'low' property". I know that cause I do not pass arguments in the "Long" constructor but it's not working iven if I don't put the "()". I'm a bit lost with that ^^'
Sorry for my english ^^'
Share Improve this question asked Jun 19, 2016 at 7:35 ColoniseurColoniseur 851 silver badge6 bronze badges1 Answer
Reset to default 6You should use a module specifically designed for Mongoose, like mongoose-long
:
var mongoose = require('mongoose')
require('mongoose-long')(mongoose);
var Long = mongoose.Schema.Types.Long;
var UserSchema = new mongoose.Schema({
id : Long,
name : String,
pleted : Long,
note : String,
updated_at : { type: Date, default: Date.now },
});
本文标签: javascriptHow use quotLongquot type in an MongoDB schema declarationStack Overflow
版权声明:本文标题:javascript - How use "Long" type in an MongoDB schema declaration? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745189453a2646842.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论