Using a collection's aggregation pipeline with all records of another collection

Advertisements I have two collections: Books { "BOOK_ID": "100", "BOOK_NAME": "Book 1", "BOOK_DESC": "abcd", }, { "BOOK_ID": "101", "BOOK_NAME": "Book 2", "BOOK_DESC": "efgh", }, { "BOOK_ID": "102", "BOOK_NAME": "Book 3", "BOOK_DESC": "ijkl", } BookGroup { "GROUP_ID": "100", "GROUP_NAME": "G1", "GROUPS": [ { "BOOK_ID": "100", "BOOK_NAME": "Book 1" }, { "BOOK_ID": "101", "BOOK_NAME": "Book 2" }… Read More Using a collection's aggregation pipeline with all records of another collection

PyMongo: Filter data from MongoDB by values from numpy.ndarray

Advertisements I’m using a pymongo to get data from collection "example" in mongodb. This collection contains next fields: _id nums (it can be: "1000", "13833", "1205" or something like this) content Example of document: { "_id": { "$oid": "12345" }, "nums": "1000", "content": [ "systematic", "review", "meta-analysis", ], } Also I have an numpy.ndarray named… Read More PyMongo: Filter data from MongoDB by values from numpy.ndarray

PyMongo save List of dict in subfield with own ObjectId for every dict entry

Advertisements I’m creating a list of Objects in my script, and want so save/update them in a subfield of an mongo db document. My Objects looks like this: class IndividualRating: def __init__(self, place=0, player="", team="", games="", legs=""): self.place = place self.player = player self.team = team self.games = games self.legs = legs in my process… Read More PyMongo save List of dict in subfield with own ObjectId for every dict entry

Pymongo "and" operator not filtering query results

Advertisements I have this monogdb schema: groups = { "bsonType": "object", "required": [ "created_at", "group_name", "owner", "members", "currency", "country", "group_username" ], "properties": { "created_at": { "bsonType": "date", "description": "The date and time when the group was created" }, "group_name": { "bsonType": "string", "description": "Name of group" }, "group_username": { "bsonType": "string", "description": "groups username" },… Read More Pymongo "and" operator not filtering query results

pymongo "Projection" to exclude all fields and only get selected fields?

Advertisements Using mongodb projection we can define which filed to include and which one to exclude. like this : data = db.Users.find_one({‘username’: user },{"_id":0,"password":0,"email":1}) This Query will exclude the _id and password fields and only include email , But is there a way to exclude all the fields present in a document and only fetch… Read More pymongo "Projection" to exclude all fields and only get selected fields?

Get data based on unique field mongodb during pagination

Advertisements Sorry if the title is wrong but here is what i am trying to do, let’s say i have the objects : {"_id": "anyID0", "contentID": "content1", "value": "any value", "at": 10} {"_id": "anyID1", "contentID": "content1", "value": "any value", "at": 9} {"_id": "anyID2", "contentID": "content2", "value": "any value", "at": 8} {"_id": "anyID3", "contentID": "content3", "value":… Read More Get data based on unique field mongodb during pagination

How can I get a subfield of dictionary in mongodb?

Advertisements I’ve the data structured as follows: { "_id" : ObjectId("61e810b946788906359966"), "titles" : { "full_name" : "full name", "name" : "name" }, "duration" : 161, "work_ids" : { "plasma_id" : "METRO_3423659", "product_code" : "34324000", } } I would like query result as: {‘full_name’: ‘full name’, ‘plasma_id’: ‘METRO_3423659’} The query that i do is: .find({query},{"_id": 0,… Read More How can I get a subfield of dictionary in mongodb?

How to find all documents in a collection Mongodb by two values of the same key?

Advertisements Tried to find the answer on the net, but somehow did not work. I have a collection from which I get a dataframe. I need to filter, that is, get all documents in which the key value will match a certain list of values. Example collection: _id: ‘1’ key_1: ‘a’ key_2 : ‘b’ _id:… Read More How to find all documents in a collection Mongodb by two values of the same key?

Adding createdAt and updatedAt in pymongo

Advertisements I want to add auto generated field created_at and updated_at in mongodb in python using pymongo. This functionality is provided in Javascript when creating mongo schema using var yourSchema = new Schema({..}, { timestamps: { createdAt: ‘created_at’, updatedAt: ‘updated_at’} }); How exactly can this be done in pymongo? >Solution : This is a mongoose… Read More Adding createdAt and updatedAt in pymongo