mongo-shell

Insert large record into mongodb using mongo shell

我的未来我决定 提交于 2021-02-15 07:50:55
问题 I'm trying to insert large polygon array into my collection. I'm using following command to insert the data... db.geoPolygonData.insert({"polygonName":"location1", "polygons":{"type":"Polygon", coordinates:[[[ 17.60083012593064, 78.18557739257812], [ 17.16834652544664, 78.19381713867188], [ 17.17490690610013, 78.739013671875], [ 17.613919673106714, 78.73489379882812],[ 17.60083012593064, 78.18557739257812]]]}}); WriteResult({ "nInserted" : 1 }) Problem: when the polygon array size is too

Insert large record into mongodb using mongo shell

老子叫甜甜 提交于 2021-02-15 07:50:13
问题 I'm trying to insert large polygon array into my collection. I'm using following command to insert the data... db.geoPolygonData.insert({"polygonName":"location1", "polygons":{"type":"Polygon", coordinates:[[[ 17.60083012593064, 78.18557739257812], [ 17.16834652544664, 78.19381713867188], [ 17.17490690610013, 78.739013671875], [ 17.613919673106714, 78.73489379882812],[ 17.60083012593064, 78.18557739257812]]]}}); WriteResult({ "nInserted" : 1 }) Problem: when the polygon array size is too

Mongo shell giving out the error “Multiple occurrences of option”

牧云@^-^@ 提交于 2021-01-28 02:27:23
问题 When using the following command mongo --username admin_user --password passw#ord^s --authenticationDatabase admin I get the error ""Error parsing command line: Multiple occurrences of option "--username". The version of Mongo shell 3.0.12. Can anybody tell me what's wrong here? 回答1: Ok. I managed to find the issue. The current user didn't seem to have permission to mongo shell properly for some reason. When I add "sudo" to the beginning it worked fine. 来源: https://stackoverflow.com/questions

Mongo shell giving out the error “Multiple occurrences of option”

自作多情 提交于 2021-01-27 22:51:53
问题 When using the following command mongo --username admin_user --password passw#ord^s --authenticationDatabase admin I get the error ""Error parsing command line: Multiple occurrences of option "--username". The version of Mongo shell 3.0.12. Can anybody tell me what's wrong here? 回答1: Ok. I managed to find the issue. The current user didn't seem to have permission to mongo shell properly for some reason. When I add "sudo" to the beginning it worked fine. 来源: https://stackoverflow.com/questions

Cannot connect to mongodb atlas through mongo shell

两盒软妹~` 提交于 2020-08-22 09:42:07
问题 I've checked other similar posts but none worked for my case. I upgraded my mongo shell right before connecting to MongoDB Atlas, from which I created a free sandbox database. I used this following for my connection, which was given by atlas. mongo "mongodb+srv://cluster0-z2lf6.mongodb.net/test" --authenticationDatabase admin --username <user> --password <password> image of the user of database: screenshot of the overview of the database: These are the detail of database: However, the

Mongo aggregate query results in less document with sorting

随声附和 提交于 2020-05-16 22:40:46
问题 I have faced a weird issue while querying one of our collections and aggregating the result out to another collection. I am querying unique users who have done some action and projecting the count of action performed per user in the aggregation query. var result = db.getCollection('user_actions').aggregate( [ {"$match":{"createdAt":{"$gte":1585161000000,"$lt":1585247340000}}}, {"$group":{"_id":{"accountId":"$user.id"},"count":{"$sum":1}}}, {"$sort": {"count": -1}}, {"$project":{"_id":0,"count

mongorestore error: Don't know what to do with the dump file [closed]

被刻印的时光 ゝ 提交于 2020-05-09 17:47:45
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I have mongo DB installed in the following path c:\mongodb\bin . I have configured my environment variable PATH in advanced settings.I also have mongod running .When I run the following command mongorestore dump from the following path c:\hw1-1\dump (This contains the BSON files) I'm getting this

How to convert NumberDecimal to Double in MongoDB shell?

心不动则不痛 提交于 2020-02-25 08:22:29
问题 I have a document with "test" filed as NumberDecimal type { "_id" : ObjectId("5d1a202e476381c30cd995a4"), "test" : NumberDecimal("0.1") } How to convert "test" field from NumberDecimal to Double in mongodb shell? I tried execute db.collection.find({"test": {$exists: true}}).forEach(function (x) { x.test = parseFloat(x.test); db.collection.save(x); }); but don't solve this problem because it return NaN 回答1: The decimal type is not native to JavaScript, so NumberDecimal values in the shell are