草庐IT

mongoose-encryption

全部标签

javascript - 为什么 Mongoose 排序比原生 javascript 排序慢?

我使用的是Node.js6.10.0和Mongoose4.8.5。实际上我正在尝试从坐标和特定日期时间找到最近的坐标。我的MongoDB中有数十亿数据。我想对我的查询进行排序,因为我想按日期时间排序(2017-03-02T03:00:00.000Z,2017-03-02T03:01:00.000Z...2017-03-02T03:23:00.000Z)所以这是我使用Mongoose排序的查询:varcondition={$nearSphere:{$geometry:{type:"Point",coordinates:[2.2871244564,47.930476456445]}}};v

mongodb - Mongoose 选择、填充和保存在 Mac 和 Windows 上的行为不同

这是我做的staticpopulateReferralLinks(){returnPromise.coroutine(function*(){letcompanies=yieldCompany.find({},'billingreferralcurrent_referral_program').populate('billing.user','emailsname');for(leti=0;i{throwerr;});}我有一个功能,我只选择3个字段继续进行,即计费、current_referral_program和referral。并使用存储在billing.user中的引用填充用户

node.js - 所需的子文档 Mongoose

我定义了以下Mongoose模式varsubSchema=newSchema({propertySub:{type:String,required:true}});varmainSchema=newSchema({mainProperty:{type:String,required:true},subs:[subSchema]});如您所见,subSchema上有一个必需的属性,问题是我希望mainSchema需要至少有一个subSchema,但是当我发送{"mainProperty":"Main"}没有失败。我试过类似的东西subs:[{type:subSchema,required

node.js - 身份验证失败 Mongoose

我正在尝试为我的mongo服务器启用身份验证。我已经完成了:-在mongo.conf中配置安全-创建用户(如果将其与mongo-u-p一起使用......从控制台工作正常)在Node服务器js中我的配置是这样的mongoose.connect(mongodb://user:pass@localhost:27017/dbName);我也试过mongoose.connect(mongodb://user:pass@localhost:27017/dbName,{auth:{authdb:"admin"}});还有这个mongoose.connect(mongodb://user:pass@

node.js - Mongoose 加密中间件聚合后不调用

我有一个带有“mongoose-encryption”插件的mongoose模式,例如:letsomeSchema=newSchema({name,age});someSchema.plugin(mongoose-encryption,{encryptionKey:'eKey',signingKey:'sKey',encryptedFields:['age'],decryptPostSave:false});启动模型和存储库后,我尝试聚合一些查询:letaggregation=[];//justreturnallthedocs.someModel.aggregate(aggregati

node.js - Mongoose Schema 数字字段的长度是准确的

我有这个moongoose模式:varuserSchema=newmongoose.Schema({firstname:{type:String,required:true,min:3,max:24},lastname:{type:String,required:true,min:3,max:24},id:{type:Number,required:true,min:9,max:9},mediations:[assetSchema]});当我尝试添加ID为320981350的新用户时,出现下一个验证错误:{"errors":{"id":{"message":"Path`id`(3209

javascript - 我们可以用 Mongoose 检索 Node js中两个表的数据吗

关闭。这个问题需要debuggingdetails.它目前不接受答案。编辑问题以包含desiredbehavior,aspecificproblemorerror,andtheshortestcodenecessarytoreproducetheproblem.这将有助于其他人回答问题。关闭4年前。Improvethisquestion我正在做一个项目,其中有一些关系概念,所以我想在同一个查询中从两个不同的表中检索数据,我可以这样做吗?我正在关注以下链接,但我没有得到我想要的确切信息。Mongoose/mongoDBqueryjoins..butIcomefromasqlbackgro

javascript - 如何使用mongoose计算mongodb集合文档中的字段总和

我想从mongodb文档中计算员工积分。我在员工积分收藏中的文件如下[{"EmployeeID":"Cust0001","Point":1,},{"EmployeeID":"Cust0002","Point":2,},{"EmployeeID":"Cust0003","Point":1,},{"EmployeeID":"Cust0001","Point":5,},{"EmployeeID":"Cust0001","Point":2,}]预期结果[{"EmployeeID":"Cust0001","Total_Points":8},{"EmployeeID":"Cust0002","To

Node.js 和 MongoDB Atlas Mongoose 连接错误

我正在尝试将MongoDBatlas实例连接到nodejs/express服务器:constmongoose=require("mongoose");constdbURI="mongodb+srv://(urlcopiedfromatlasconnect)";constoptions={useNewUrlParser:true,dbName:"data"};mongoose.connect(dbURI,options).then(()=>{console.log("Databaseconnectionestablished!");},err=>{console.log("Errorco

node.js - 在 Mongoose 中按月分组

这个问题在这里已经有了答案:MongoDbHowtogroupbymonthandyearfromstring(1个回答)关闭4年前。我有费用明细,我想在其中按月对费用进行分组,并返回月份和该特定月份的费用。我什至检查了Mongoose文档,以根据月份进行汇总,但我的数据不符合他们的标准,因为我正在保存日期,如12-Jan-2018.有什么方法可以让我获得当月的月份和总金额。我想要类似-Jan:50,Feb:45等等...下面是样本集{"_id":{"$oid":"5babee47a7d56e5fb896f181"},"date":"07-Sep-2018","expenseInfo"