草庐IT

insert-query

全部标签

node.js - 蒙戈/ express : How to return all documents in collection if no query params are passed?

如果没有传递查询参数,我将尝试从我的Mongo集合中返回所有文档。目前我有3个可选的查询参数可以由用户传递。localhost:3000/api/projects//shouldreturnallprojects.Currentlythisisreturning[]localhost:3000/api/projects?id=1//shouldreturnprojectswithidof"1".Workingproperly.localhost:3000/api/projects?name=myproject//shouldreturnprojectswithnameof"myproj

mongodb - 蒙戈 : querying for values nested in child arrays where keys are variable

我正在尝试构建一个Mongo查询,我可以在其中根据子数组中的值选择文档,其中嵌入数组的键会随着文档的不同而变化。在下面的示例中,我们有三个文档数组。提取每种酒的名称是微不足道的。当我想选择品尝结果大于20的Wine时,问题就来了。问题是我在运行查询时不知道航类名称;它可以是任何东西。因此,我不能只检查嵌入式数组的值。我想过类似的事情$ary_query=array('tasting_results.*'=>'$gt:20');但显然通配符在Mongo中不起作用(至少不是那样)。有什么想法吗?这是示例数组:ary_wines=array("name"=>"Ripple","year"=>

c# - FluentMongo LINQ : How to query a sublist of a class

假设我有这样一个类:publicclassBOa{publicObjectIdId{get;set;}publicstringName{get;set;}publicListVisiteEffettuate=newList();}publicclassBOvalues{publicDateTimeData{get;set;}publicintAge{get;set;}publicintScore{get;set;}}明确地说,在MongoDB中,我有许多BOa的集合。他们每个人都包含许多(一系列......)BOvalues我想知道如何使用FluentMongoLINQ(或其他方法)获

mongodb - Mongoose query.populate 只返回 objectId

当尝试填充一个字段时,所有返回的都是最初为该字段保存的objectid在models/gifts.jsvarGiftSchema=newSchema({name:String,owner:{user:{type:Schema.Types.ObjectId,ref:'User',required:false},nonRegisteredEmail:{type:String,required:false},nonRegisteredName:{type:String,required:false}},description:String,url:String}});module.expor

javascript - MongoDB 外壳 : Query BinData by Type

我正在尝试通过使用BinData的_id字段查询大型集合。其中一些ID使用类型4的BinData:"_id":BinData(4,"CNDF66qIlCY92q1vFAAAAQ==")虽然有些使用类型3的BinData:"_id":BinData(3,"CNDF66qJ29g92q1vFAAAEw==")我需要找到BinData.type=3的所有_id字段,并且想知道是否有人在MongoDBshell中幸运地进行了这样的查询。如有任何帮助,我们将不胜感激! 最佳答案 您可以使用$where样式查询来执行此操作,因为BinData对

python - MongoDB/PyMongo : BadValue Unsupported projection option when trying to query all dates after

我构建了一个将推文存储到MongoDB中的Twitter抓取工具。现在我正在尝试使用PyMongo查询数据。在我的MongoDB中存储的数据:{"_id":{"$oid":"5555dc0e50f808afe0da52fe"},"text":"LoremIpsum...","created_at":{"$date":"2015-05-15T10:55:16.000Z"},}以下工作非常好(但获取每条推文):dikt1={}tweets_iterator=coll.find({},{"text":1,"user.screen_name":1,created_at':1})fortweet

mysql - MongoDB : Query based on time in ISODate format

假设Mongodb数据库中的示例文档如下:{"date":ISODate("2015-11-09T05:58:19.474Z")}{"date":ISODate("2014-10-25T07:30:00.241Z")}{"date":ISODate("2015-11-30T15:24:00.251Z")}{"date":ISODate("2012-01-10T18:36:00.101Z")}预期:{"date":ISODate("2015-11-09T05:58:19.474Z")}{"date":ISODate("2014-10-25T07:30:00.241Z")}我有兴趣查找“日

javascript - 无法读取 underfined mongoDB NodeJS 的 'insert' 的属性

我正在尝试将mongoDB合并到我的应用程序中,但是当我尝试添加到集合中时,在尝试使用nodeJS启动服务器时出现错误“无法读取未定义的‘插入’属性。”我很感激之前有人问过这个问题,但是当我尝试通过编写以下代码来根据此处提出的另一个问题纠正错误时,但是我得到varisnotdefined;varaccountCollection=varmongodb=mongodb.collection('account');accountCollection.insert({用户名:"wendy3",密码:"lilac3"});下面是我的服务器的相关代码,我在网上看了很多指南,似乎没有什么能解决我的

node.js - Can't query date from MongoDB(Mlab) -- 如此简单却无法解决

经过数周的努力,我仍然无法使用NodeJS从Mlab查询具有以下结构的日期字段movie_datetime。"movie_datetime":{"$date":"2017-01-03T16:00:00.000Z"},"session_id":31268我尝试了以下方法db.mycollection.find({"movie_datetime":{"gte":{"$date":"2013-10-01T00:00:00.000Z"}}})db.mycollection.find({"movie_datetime":{"$gte":newDate("2013-10-01T00:00:00.0

mongodb : Query array of nested string

我有一个类似的对象列表[{item:"journal",instock:[{warehouse:"A",qty:5},{warehouse:"C",qty:15,type:["hello","world","wassup","yo"]}]},{item:"notebook",instock:[{warehouse:"C",qty:5}]},{item:"paper",instock:[{warehouse:"A",qty:60},{warehouse:"B",qty:1515,type:["hello","wassup","yo"]}]},{item:"planner",instock