Closed roosht3 closed 7 years ago
in Model
static get objectIdFields() { return ['_id', 'timeline_id', 'type_id'] }
In Controller
//below query doesn't work tours = yield Tour.with(['type']).where('type_id', typeFilter).paginate(request.input('page', 1), 20);
Lucid find() with([type]) returns the correct results.
Tour { attributes: { _id: 59000f5c898d9a03481b5ed4, name: 'Canada Ontario Trip', desc: 'a marvellous trip suthi parka porom', active: 1, adults: 10, children: 0, type_id: '590819ce4671a409ac276589', price: 50, discounted_rate: '10%', popular: '', featured: '', schedules: [ [Object], [Object] ], created_at: moment.utc("2017-04-26T03:09:14.943+00:00"), updated_at: moment.utc("2017-04-26T03:09:14.943+00:00") }, original: { _id: 59000f5c898d9a03481b5ed4, name: 'Canada Ontario Trip', desc: 'a marvellous trip suthi parka porom', active: 1, adults: 10, children: 0, type_id: '590819ce4671a409ac276589', price: 50, discounted_rate: '10%', popular: '', featured: '', schedules: [ [Object], [Object] ], created_at: moment.utc("2017-04-26T03:09:14.943+00:00"), updated_at: moment.utc("2017-04-26T03:09:14.943+00:00") }, unsetFields: [], transaction: null, relations: { type: Type { attributes: [Object], original: [Object], unsetFields: [], transaction: null, relations: {}, exists: true, frozen: false, eagerLoad: [Object] } }, exists: true, frozen: false, eagerLoad: EagerLoad { withRelations: [], withNestedRelations: {}, relationsScope: {}, nestedRelationsScope: {} } }
If you want to enter relationship manually, You have to enter it like
"type_id": { "$oid": "590819cd4671a409ac276587" }
not
"type_id": "590819cd4671a409ac276587",
in Model
In Controller
Lucid find() with([type]) returns the correct results.