Loopback AngularJS SDK and Get Data
I'm newer with Loopback.js
I have a lot of collection in MongoDB and I thought index field is the best way to relationship with two collection. For example,
I have two collections. These are Projects and Job
They have "ProjectID" table for hasMany relation. The project collection has many jobs. Look at this image.
This is other picture for create collection from loopback gui.
My question: I tried get _id field (it is also ProjectID) from database.Here is:
// Get Projects Data
if (typeof Projects.find({}) != "undefined") {
$scope.projects = Projects.find({});
}
console.log($scope.projects);
But my result is in this picture :
Why I can't access _id
or ProjectID
? Do I any mistake?
If you know other good way for relation, you should tell me.
Thank you for answers.
I solved this problem.
You don't need to create other field for collection relation.
Delete all ID fields (like ProjectID, JobID, etc...) and use
command. Thanks to this command create relation with own collection id.
The problem took my 5 hour, it maybe helpful other developer. Happy coding.