jjzjj

insertmany

全部标签

javascript - 类型错误 : mongodb property insertmany is not a function

db.col.insertMany([{"_id":"tt0084726","title":"StarTrekII:TheWrathofKhan","year":1982,"type":"movie"},{"_id":"tt0796366","title":"StarTrek","year":2009,"type":"movie"},{"_id":"tt0084726","title":"StarTrekII:TheWrathofKhan","year":1982,"type":"movie"}]);OS:LinuxMint17.3RosaMongoDB:dbversionv2.6.1

javascript - NodeJS 和 mongo : insertMany changing value from data in the callback function

如果有这段代码,我在mongodbNode中插入许多项目:constextractions=[{name:'xpto'},{name:'otherxpto'}]console.log('extractionsbefore',extractions)dbase.collection('someendpoint').insertMany(extractions,(err,data)=>{console.log('extractionsafter',extractions)})奇怪的是,inserMany()方法正在更改extractions常量(将_id添加到每个项目),如下所示:输出:e

c# - 在 Mongodb 中使用 insertmany 时如何避免 "Maximum serialisation depth exceeded"

从Azure保存磁盘信息:varcredentials=SdkContext.AzureCredentialsFactory.FromServicePrincipal("myclientId","mytenant","mysecretId",AzureEnvironment.AzureGlobalCloud);varazure=Azure.Authenticate(credentials).WithSubscription("mySubscription");vargroupName="myResourceGroup";varvmName="myVM";varlocation=Regi

node.js - db.collection.insert 与 db.collection.insertOne 和 db.collection.insertMany 的性能影响

我正在为NodeJs使用mongodb驱动程序,其中有3个方法:1)db.collection.insert2)数据库.collection.insertOne3)db.collection.insertMany我发现db.collection.insert完成了insertOne和insertMany的工作。我也找到了相同的删除和更新方法。相对于db.collection.insertOne和db.collection.insertMany方法,调用db.collection.insert方法对性能有影响吗?可以安全地假设我在某个时间点将拥有数百万条记录的集合中工作。

mongodb - InsertMany 在 mongodb 中不起作用

我对Mongoose和MongoDB本身还很陌生,我正在尝试保存一堆通过insertMany方法插入的文档,但它并没有保存文档。这是我的代码:型号:varmongoose=require('mongoose');varSchema=mongoose.Schema;varhostSchema=newSchema({hostname:String,timestamp:Number,});varhostModel=mongoose.model('host',hostSchema,'host');module.exports=hostModel;ExpressJS邮政路线varmongoose

javascript - insertMany 不是函数

在我的项目中,我正在制作一个系统,让用户可以创建和配置他们自己的足球锦标赛。比赛结束后,我必须将poules和团队放入mongo的比赛文件中。我不断收到以下错误:TypeError:toernooi.insertManyisnotafunctionatC:\xampp\htdocs\nodeprojects\contactlistapp\server.js:254:13atQuery.(C:\xampp\htdocs\nodeprojects\contactlistapp\node_modules\mongoose\lib\model.js:3398:16)atC:\xampp\htd

node.js - insertMany处理重复错误

我想将insert(对象数组)批量插入到文档中,但是我想防止重复的记录,找不到使用insertMany做到这一点的方法。constSong=require('../models/song');Song.insertMany([{id:1,name:"something"},{id:2,name:"somethingelse"]).then((result)=>{res.json({result})})上面的代码可以工作,但是如果记录相同,它将仍然被插入。 最佳答案 好吧,实际上,MongoDB默认情况下不会在涉及“唯一键”的情况下创

javascript - insertMany 总是返回重复的 _id 错误

我有一个Mongo集合,我正在尝试将多个文档插入其中,如下所示:db.collection('properties').insertMany(docs).catch(err=>console.log(err)).then((err,result)=>{console.log(err);console.log(docs);console.log(result);//if(err)console.log(err);//elseif(callback)callback();});这总是返回以下错误:{[MongoError:insertDocument::causedby::11000E11

javascript - 函数 insertMany() 无序 : proper way to get both the errors and the result?

好像是MongoDBinsertMany()将ordered选项设置为false的函数可以比ordered选项设置为true更有效地插入文档。即使多个文档插入失败,它也可以继续插入文档。但是我发现没有一种干净的方法可以同时获取每个失败文档的错误和整体命令结果。(顺便说一句,我使用的是Node.js驱动程序API2.2。从现在开始我将引用驱动程序的源代码:http://mongodb.github.io/node-mongodb-native/2.2/api/lib_collection.js.html)首先,如果使用Promise,则无法同时获取错误和结果。在源代码第540行,inse

mongodb - DeprecationWarning : collection. 插入已弃用。改为使用 insertOne、insertMany 或 bulkWrite

我正在为Ionic前端开发LoopBack后端。它使用MongoDB作为数据库。在package.json中,我尝试将依赖项loopback-connector-mongodb从升级到^3.6.0>^3.4.1,但我遇到了这种警告。DeprecationWarning:collection.insertisdeprecated.UseinsertOne,insertManyorbulkWriteinstead.但是,我仍然没有找到解决方案,所以我想我必须再次降级。(如果是这样,就没有这样的警告¯_(ツ)_/¯)有更好的解决方案吗?谢谢。 最佳答案