objectid

Mongoose object id constraint

喜你入骨 提交于 2021-01-28 21:13:48
问题 hello I'm working with mongoose and after a long time I still dont know how to fix this error... I tried during several hours to fix it but every time I just 'hide' the problem by complete the field with random character but for my project I cant, I need a precise Id so if someone could help with an example if he can, it will be really nice Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters I m trying to create an Id like : map1AssigneSeat And to

How to find document by parts of ObjectId?

狂风中的少年 提交于 2021-01-27 18:09:50
问题 For some reason I use MongoDB native ObjectId as primary key for ticket identification number for my application. Is it possible to search documents with ObjectId parts? For example: I have documents: [ {_id: ObjectId("577f8e6537e4a676203c056a")}, {_id: ObjectId("577f8ee437e4a676203c0577")}, {_id: ObjectId("577f8f3d717b6fdd22a1684c")} ] And I want to query it by its _id contains "0577" so that it returns {_id: ObjectId("577f8ee437e4a676203c0577")} I have tried regex before. It returned [] db

How to decrypt mongodb objectId on Nodejs CosomosDB Trigger

笑着哭i 提交于 2020-06-28 03:57:08
问题 I am retrieving my azure cosmosdb/mongodb document from a custom trigger to azure functions.. But my objectId seems to be encrypted.. How to get the correct objectid.. for example ObjectId("5df88e60d588f00c32a3c9ce") is coming as ]øŽ`Õˆð2£ÉÎ or ObjectId("5df88f92d588f00c32a3c9d1") is coming as ]ø’Õˆð2£ÉÑ Is there a way to retrieve objectid in nodejs/python or any script if i give ]ø’Õˆð2£ÉÑ as input. This is my function.json used in the azure function { "scriptFile": "__init__.py", "bindings"

Sub-query in MongoDB

ⅰ亾dé卋堺 提交于 2020-05-14 22:05:14
问题 I have two collections in MongoDB, one with users and one with actions. Users look roughly like: {_id: ObjectId("xxxxx"), country: "UK",...} and actions like {_id: ObjectId("yyyyy"), createdAt: ISODate(), user: ObjectId("xxxxx"),...} I am trying to count events and distinct users split by country. The first half of which is working fine, however when I try to add in a sub-query to pull the country I only get nulls out for country db.events.aggregate({ $match: { createdAt: { $gte: ISODate(

Sub-query in MongoDB

孤街醉人 提交于 2020-05-14 22:05:01
问题 I have two collections in MongoDB, one with users and one with actions. Users look roughly like: {_id: ObjectId("xxxxx"), country: "UK",...} and actions like {_id: ObjectId("yyyyy"), createdAt: ISODate(), user: ObjectId("xxxxx"),...} I am trying to count events and distinct users split by country. The first half of which is working fine, however when I try to add in a sub-query to pull the country I only get nulls out for country db.events.aggregate({ $match: { createdAt: { $gte: ISODate(

mongoose query: find an object by id in an array

Deadly 提交于 2020-03-17 11:57:10
问题 How could I find an image by id in this Schema. I have the id of the User and the id of the image I am looking for. What would be the best way to do this and do all images in this case have different ids or could they have the same id because they don't belong to the same User? My Schema looks like this: var userSchema = new Schema({ local: { email: String, password: String }, facebook: { id: String, token: String, email: String, name: String }, name: String, about: String, images: [{ id: