coresmart / persistencejs

persistence.js is an asynchronous Javascript database mapper library. You can use it in the browser, as well on the server (and you can share data models between them).
http://persistencejs.org
1.73k stars 240 forks source link

many-to-many relation question #162

Open mueees opened 9 years ago

mueees commented 9 years ago

If i have many-to-many relation, such Task and Tag and one task has two tags

task.tag.add(tag1) task.tag.add(tag2);

What is the right way to get task with related tags?

Is it right ? Task.all().list(function(tasks){ var task = task[0]; task.tag.list(function(tags){ task.tagsData = tags; }) })

Thanks for answer.