i have a model that it has some json type attribute and now I want to use find on this json attribute. may please help how can i do it?
model:
module.exports = {
attributes: {
ownerInfo: {
type: 'json',
description: 'owner info of Task',
example: {id: '', fullName: '', emailAddress: ''}
},
name: {
type: 'string',
required: true,
description: 'Name of Task',
example: 'Business App'
},
users: {
type: 'json',
columnType: 'array',
description: 'Users id of task',
defaultsTo: [],
example: [{id :'', emailAddress: '', fullName: '', status: ['admin', 'leader', 'user']}]
}
}
}
actually i need 2 different query, one for finding ownerInfo.id and another else is finding user[].id. in second query attribute is Array.
I searched a lot in Internet and tried many time with the queries like below but have not got any result.
tasks = await Task.find({
where: {
ownerInfo: {
id: params.id
}
}
})
for Array i had no any Idea how to search in Array of Object. please share your Idea.
tasks = await Task.find({
where: {
users: {
// how to search status of user ??
}
}
})
and also in MongoDb better I save short user info in task collection or like relative DB only keep the id of them and with populate reach that data? which method is faster and better as performance?
advanced thanks