mongoengine get value on nested field [duplicate]
This question is an exact duplicate of:
mongoengine - Query on ListField of EmbeddedDocumentField
1 answer
I have following list in mongodb.
> db.article.find().pretty()
"_id" : ObjectId("5bebcfbb1b48d9974aac78ee"),
"no" : 40,
"subject" : "string",
"content" : "string",
"userid" : "string",
"comments" : [
"no" : 1,
"content" : "First content",
"userid" : "john",
"parent" : null,
"seq" : 12,
"created_at" : ISODate("2018-11-14T16:33:01.943Z")
,
"no" : 2,
"content" : "Second",
"userid" : "doe",
"parent" : null,
"seq" : 25,
"created_at" : ISODate("2018-11-14T16:33:01.943Z")
,
Now I'm using mongoengine
in my python app.
If I want to get comments's no: 2's seq
field value(in this code, it is 25), how can I manipulate my query?
I found the docs related it(http://docs.mongoengine.org/guide/querying.html) But I don't know it is exactly same with what I want.
Any solution here?
Thanks!
python mongodb mongoengine
marked as duplicate by Neil Lunn
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 14 '18 at 8:19
This question was marked as an exact duplicate of an existing question.
add a comment |
This question is an exact duplicate of:
mongoengine - Query on ListField of EmbeddedDocumentField
1 answer
I have following list in mongodb.
> db.article.find().pretty()
"_id" : ObjectId("5bebcfbb1b48d9974aac78ee"),
"no" : 40,
"subject" : "string",
"content" : "string",
"userid" : "string",
"comments" : [
"no" : 1,
"content" : "First content",
"userid" : "john",
"parent" : null,
"seq" : 12,
"created_at" : ISODate("2018-11-14T16:33:01.943Z")
,
"no" : 2,
"content" : "Second",
"userid" : "doe",
"parent" : null,
"seq" : 25,
"created_at" : ISODate("2018-11-14T16:33:01.943Z")
,
Now I'm using mongoengine
in my python app.
If I want to get comments's no: 2's seq
field value(in this code, it is 25), how can I manipulate my query?
I found the docs related it(http://docs.mongoengine.org/guide/querying.html) But I don't know it is exactly same with what I want.
Any solution here?
Thanks!
python mongodb mongoengine
marked as duplicate by Neil Lunn
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 14 '18 at 8:19
This question was marked as an exact duplicate of an existing question.
add a comment |
This question is an exact duplicate of:
mongoengine - Query on ListField of EmbeddedDocumentField
1 answer
I have following list in mongodb.
> db.article.find().pretty()
"_id" : ObjectId("5bebcfbb1b48d9974aac78ee"),
"no" : 40,
"subject" : "string",
"content" : "string",
"userid" : "string",
"comments" : [
"no" : 1,
"content" : "First content",
"userid" : "john",
"parent" : null,
"seq" : 12,
"created_at" : ISODate("2018-11-14T16:33:01.943Z")
,
"no" : 2,
"content" : "Second",
"userid" : "doe",
"parent" : null,
"seq" : 25,
"created_at" : ISODate("2018-11-14T16:33:01.943Z")
,
Now I'm using mongoengine
in my python app.
If I want to get comments's no: 2's seq
field value(in this code, it is 25), how can I manipulate my query?
I found the docs related it(http://docs.mongoengine.org/guide/querying.html) But I don't know it is exactly same with what I want.
Any solution here?
Thanks!
python mongodb mongoengine
This question is an exact duplicate of:
mongoengine - Query on ListField of EmbeddedDocumentField
1 answer
I have following list in mongodb.
> db.article.find().pretty()
"_id" : ObjectId("5bebcfbb1b48d9974aac78ee"),
"no" : 40,
"subject" : "string",
"content" : "string",
"userid" : "string",
"comments" : [
"no" : 1,
"content" : "First content",
"userid" : "john",
"parent" : null,
"seq" : 12,
"created_at" : ISODate("2018-11-14T16:33:01.943Z")
,
"no" : 2,
"content" : "Second",
"userid" : "doe",
"parent" : null,
"seq" : 25,
"created_at" : ISODate("2018-11-14T16:33:01.943Z")
,
Now I'm using mongoengine
in my python app.
If I want to get comments's no: 2's seq
field value(in this code, it is 25), how can I manipulate my query?
I found the docs related it(http://docs.mongoengine.org/guide/querying.html) But I don't know it is exactly same with what I want.
Any solution here?
Thanks!
This question is an exact duplicate of:
mongoengine - Query on ListField of EmbeddedDocumentField
1 answer
python mongodb mongoengine
python mongodb mongoengine
asked Nov 14 '18 at 8:15
HideHide
395212
395212
marked as duplicate by Neil Lunn
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 14 '18 at 8:19
This question was marked as an exact duplicate of an existing question.
marked as duplicate by Neil Lunn
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 14 '18 at 8:19
This question was marked as an exact duplicate of an existing question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
db.getCollection('article').aggregate([
"$project":"comments.seq":1,"comments.no":1,"_id":0,
"$unwind":"$comments",
"$match":"comments.no":NumberInt(2),
"$project":"comments.seq":1
])
You can refer to it.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
db.getCollection('article').aggregate([
"$project":"comments.seq":1,"comments.no":1,"_id":0,
"$unwind":"$comments",
"$match":"comments.no":NumberInt(2),
"$project":"comments.seq":1
])
You can refer to it.
add a comment |
db.getCollection('article').aggregate([
"$project":"comments.seq":1,"comments.no":1,"_id":0,
"$unwind":"$comments",
"$match":"comments.no":NumberInt(2),
"$project":"comments.seq":1
])
You can refer to it.
add a comment |
db.getCollection('article').aggregate([
"$project":"comments.seq":1,"comments.no":1,"_id":0,
"$unwind":"$comments",
"$match":"comments.no":NumberInt(2),
"$project":"comments.seq":1
])
You can refer to it.
db.getCollection('article').aggregate([
"$project":"comments.seq":1,"comments.no":1,"_id":0,
"$unwind":"$comments",
"$match":"comments.no":NumberInt(2),
"$project":"comments.seq":1
])
You can refer to it.
edited Nov 14 '18 at 8:37
Unheilig
12k165387
12k165387
answered Nov 14 '18 at 8:32
KrloyKrloy
261
261
add a comment |
add a comment |