-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Hello,
I'm trying to get all Person with specific hobbyIds, but it seems like $in is not working for array fields. Is there any other option that I can use to query for people with specific hobbyIds?
var odm = jsonOdm;
odm.addSource("people",{
"Person" : [
{"id":1,"name":"Richi",jobId:8,hobbyIds:[1]},
{"id":2,"name":"Dave",jobId:2,hobbyIds:[2,4]},
{"id":3,"name":"Tom",jobId:3,hobbyIds:[3,5]},
{"id":4,"name":"Lisa",jobId:4,hobbyIds:[1,2,3]},
{"id":5,"name":"Hanni",jobId:3,hobbyIds:[1,5]},
{"id":6,"name":"Selma",jobId:8,hobbyIds:[1,4]},
{"id":7,"name":"Ralf",jobId:1,hobbyIds:[4,3]}
],
"Jobs" : [
{"id":8,"name":"plumber"},
{"id":2,"name":"programmer"},
{"id":3,"name":"chef"},
{"id":4,"name":"hairdresser"}
],
"Hobbies" : [
{"id":1,"name":"swimming"},
{"id":2,"name":"cycling"},
{"id":3,"name":"fishing"},
{"id":4,"name":"coding"},
{"id":5,"name":"dancing"}
]
},true);
// instantiate a collection object
var people = new odm.Collection('Person');
people.$hasOne("jobId","id","Jobs","job");
people.$hasMany("hobbyIds","id","Hobbies","hobbies");
var hairdresser = people.$query()
.$branch("hobbyIds").$in([1])
.$all();
console.log(hairdresser);
The code returns an empty array.
Metadata
Metadata
Assignees
Labels
No labels