Use of persistencejs in angularjs

57 views
Skip to first unread message

Jeff MAURY

unread,
Jan 31, 2016, 7:12:42 AM1/31/16
to persistence.js
Hello,

I'm using persistencejs in a Cordova/Angular/Ionic application and I'm trying to guess how to use p.js in an Angular application.
I have a main table called Training and each training have a one to many relation to the Activity table.
When I start the application the list of Training is displayed and I way have to explose an array of Training to Angular using Training.list.
Now, I can display a training (using Training.load but I don't understand how to expose the activity relationship.
From the angular point of view, the Training class/constructor allow to access primitive properties (name,...) but how to access the activity relation ?

Regards
Jeff

Dilhan Jayathilake

unread,
Oct 31, 2016, 8:43:41 AM10/31/16
to persistence.js
First you have to define the relationship like this:
Training.hasMany('activities', Activity, 'TrainingID');
Then you can query like this:
var allTrainings = Training.all().prefetch("activities").list();
Reply all
Reply to author
Forward
0 new messages