mongodb-query

Getting ancestors in MongoDb using tree structure

亡梦爱人 提交于 2021-01-01 13:07:09
问题 I have the following collection representing the directory structure. I'd like to write an aggregation query that will return all child directory IDs starting from a certain point . For example: Starting from root : results: child_A , child_B , child_A_1 Starting from child_a : results: child_A_1 I've created the following query (in Mongo 4.2) according to the docs, but I'm unable to run it successfully. [{ $match: { _id: ObjectId('5de7a00bf3663d0805644b91') } }, { $graphLookup: { from:

Getting ancestors in MongoDb using tree structure

穿精又带淫゛_ 提交于 2021-01-01 13:03:24
问题 I have the following collection representing the directory structure. I'd like to write an aggregation query that will return all child directory IDs starting from a certain point . For example: Starting from root : results: child_A , child_B , child_A_1 Starting from child_a : results: child_A_1 I've created the following query (in Mongo 4.2) according to the docs, but I'm unable to run it successfully. [{ $match: { _id: ObjectId('5de7a00bf3663d0805644b91') } }, { $graphLookup: { from:

Getting ancestors in MongoDb using tree structure

拜拜、爱过 提交于 2021-01-01 13:02:49
问题 I have the following collection representing the directory structure. I'd like to write an aggregation query that will return all child directory IDs starting from a certain point . For example: Starting from root : results: child_A , child_B , child_A_1 Starting from child_a : results: child_A_1 I've created the following query (in Mongo 4.2) according to the docs, but I'm unable to run it successfully. [{ $match: { _id: ObjectId('5de7a00bf3663d0805644b91') } }, { $graphLookup: { from:

Getting ancestors in MongoDb using tree structure

為{幸葍}努か 提交于 2021-01-01 13:00:26
问题 I have the following collection representing the directory structure. I'd like to write an aggregation query that will return all child directory IDs starting from a certain point . For example: Starting from root : results: child_A , child_B , child_A_1 Starting from child_a : results: child_A_1 I've created the following query (in Mongo 4.2) according to the docs, but I'm unable to run it successfully. [{ $match: { _id: ObjectId('5de7a00bf3663d0805644b91') } }, { $graphLookup: { from:

Getting ancestors in MongoDb using tree structure

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-01 12:56:23
问题 I have the following collection representing the directory structure. I'd like to write an aggregation query that will return all child directory IDs starting from a certain point . For example: Starting from root : results: child_A , child_B , child_A_1 Starting from child_a : results: child_A_1 I've created the following query (in Mongo 4.2) according to the docs, but I'm unable to run it successfully. [{ $match: { _id: ObjectId('5de7a00bf3663d0805644b91') } }, { $graphLookup: { from:

How to use NOT IN array condition inside mongodb $lookup aggregate

匆匆过客 提交于 2020-12-26 09:11:42
问题 I have two collections: Users: { _id: ObjectId('5e11d2d8ad9c4b6e05e55b82'), name:"vijay" } Followers : { _id:ObjectId('5ed0c8faac47af698ab9f659'), user_id:ObjectId('5e11d2d8ad9c4b6e05e55b82'), following:[ ObjectId(5ee5ca5fac47af698ab9f666'), ObjectId('5df7c0a66243414ad2663088') ] created_at:"2020-05-29T08:34:02.959+00:00" } I need to list all users who are not in the following array from users table for a particular user, I've come up with the below by writing aggregate function in followers

How to use NOT IN array condition inside mongodb $lookup aggregate

☆樱花仙子☆ 提交于 2020-12-26 09:10:38
问题 I have two collections: Users: { _id: ObjectId('5e11d2d8ad9c4b6e05e55b82'), name:"vijay" } Followers : { _id:ObjectId('5ed0c8faac47af698ab9f659'), user_id:ObjectId('5e11d2d8ad9c4b6e05e55b82'), following:[ ObjectId(5ee5ca5fac47af698ab9f666'), ObjectId('5df7c0a66243414ad2663088') ] created_at:"2020-05-29T08:34:02.959+00:00" } I need to list all users who are not in the following array from users table for a particular user, I've come up with the below by writing aggregate function in followers

How to use NOT IN array condition inside mongodb $lookup aggregate

☆樱花仙子☆ 提交于 2020-12-26 09:09:41
问题 I have two collections: Users: { _id: ObjectId('5e11d2d8ad9c4b6e05e55b82'), name:"vijay" } Followers : { _id:ObjectId('5ed0c8faac47af698ab9f659'), user_id:ObjectId('5e11d2d8ad9c4b6e05e55b82'), following:[ ObjectId(5ee5ca5fac47af698ab9f666'), ObjectId('5df7c0a66243414ad2663088') ] created_at:"2020-05-29T08:34:02.959+00:00" } I need to list all users who are not in the following array from users table for a particular user, I've come up with the below by writing aggregate function in followers

How to use NOT IN array condition inside mongodb $lookup aggregate

▼魔方 西西 提交于 2020-12-26 09:09:31
问题 I have two collections: Users: { _id: ObjectId('5e11d2d8ad9c4b6e05e55b82'), name:"vijay" } Followers : { _id:ObjectId('5ed0c8faac47af698ab9f659'), user_id:ObjectId('5e11d2d8ad9c4b6e05e55b82'), following:[ ObjectId(5ee5ca5fac47af698ab9f666'), ObjectId('5df7c0a66243414ad2663088') ] created_at:"2020-05-29T08:34:02.959+00:00" } I need to list all users who are not in the following array from users table for a particular user, I've come up with the below by writing aggregate function in followers

Query with string date format in mongodb

帅比萌擦擦* 提交于 2020-12-26 07:14:44
问题 I have a data like below in my mongoDB collection. I want to count the total number or search_term on today basis. _id:ObjectId("5b7e1d38981cdc1a7c8bb5fc") search_term:"Baiyoke Boutique" date:"August 23rd 2018, 9:34:32 am" _id:ObjectId("5b7e1fa8fa27fd2754080ad9") search_term:"Baiyoke Boutique" date:"August 23rd 2018, 9:44:56 am" _id:ObjectId("5b7e28314d2d0f388c1596cd") search_term:"Baiyoke Florting Market" date:"August 23rd 2018, 10:21:21 am" I have tried following query. I have used moment.