Can't find and updating

8 views
Skip to first unread message

HeiHeShang

unread,
Feb 16, 2012, 8:21:40 AM2/16/12
to mongodb-user
I'v next schema
Castomer = new Schema({
'name': { type: String, index: true },
'group':{type:Boolean},
'icon':{type:String},
'email':{type:String},
'address':{type:String},
'responsible':{type:String},
'activity':{type:String},
'inn': {type: String, index: true},
'users': [Schema.ObjectId],
'castomer_id': ObjectId,
'child' : [Castomer]
});

my data
{ _id: 4f2d495736343fbf5b000002,
name: 'My',
child:
[ { users: [],
child: [],
_id: 4f2fe7676c4096255a000005,
isGroup: 0,
inn: '32432',
name: 'dfgdf' },
{ users: [Object],
child: [],
_id: 4f390749c10c5bee12000009,
activity: 'ewwer',
responsible: 'апвапав',
address: '2',
email: '',
icon: '/images/Oxygen/16/actions/bookmark-new.png',
isGroup: 0,
inn: '342324324',
name: 'SDDSsdf' },
{ users: [Object],
child: [],
_id: 4f39d519c10c5bee12000013,
activity: 'ewwer',
responsible: 'апвапав',
address: '2',
email: '',
icon: '/images/Oxygen/16/actions/bookmark-new.png',
isGroup: 0,
inn: '342324324',
name: 'EEWFDS' } ],
users: [ 4f2544d902cd3ece04000001 ] }

my query :
req.body._id=4f39d519c10c5bee12000013

Castomer.findOne({ "child._id" :
mongoose.Types.ObjectId(req.body._id)},function (err,castomer) {
console.log(castomer);
});

findOne - finds
{ _id: 4f2d495736343fbf5b000002,
name: 'My',
child:
[ { users: [],
child: [],
_id: 4f2fe7676c4096255a000005,
isGroup: 0,
inn: '32432',
name: 'dfgdf' },
{ users: [Object],
child: [],
_id: 4f390749c10c5bee12000009,
activity: 'ewwer',
responsible: 'апвапав',
address: '2',
email: '',
icon: '/images/Oxygen/16/actions/bookmark-new.png',
isGroup: 0,
inn: '342324324',
name: 'SDDSsdf' },
{ users: [Object],
child: [],
_id: 4f39d519c10c5bee12000013,
activity: 'ewwer',
responsible: 'апвапав',
address: '2',
email: '',
icon: '/images/Oxygen/16/actions/bookmark-new.png',
isGroup: 0,
inn: '342324324',
name: 'EEWFDS' } ],
users: [ 4f2544d902cd3ece04000001 ] }

However I should find -
{ users: [Object],
child: [],
_id: 4f39d519c10c5bee12000013,
activity: 'ewwer',
responsible: 'апвапав',
address: '2',
email: '',
icon: '/images/Oxygen/16/actions/bookmark-new.png',
isGroup: 0,
inn: '342324324',
name: 'EEWFDS' }
How correctly to find and renew this element ???

Christian Kvalheim

unread,
Feb 20, 2012, 6:49:37 AM2/20/12
to mongod...@googlegroups.com
This is easier to get a question about at the mongoose forum


or the irc channel on freenode

#mongoosejs

Cheers
Reply all
Reply to author
Forward
0 new messages