HeiHeShang
unread,Feb 16, 2012, 8:21:40 AM2/16/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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 ???