I'm trying to create a tree structure using associations in Waterline which in the end connects to a MongoDB database. The definition of a treee no is:
TreeNode.js
module.exports = {
attributes: {
name: 'string',
childrenCategory: 'string',
parent: {
model: 'TreeNode'
},
children: {
collection: 'TreeNode',
via: 'parent'
}
}
};
And that's it for my tree structure. This node reference itself having multiple childrens of the same node and a unique parent, again of the same node. Populating these tree seems to be working. But trying to find node with a given 'parent' does not. The following query gives nothing:
TreeNode.find().where({parent: someId}).exec(function (err, r) {}
Any ideas? Also, what do you think about this tree structure? Thanks!