Open larifari opened 8 years ago
I did try, it didn't not work, at least not in the way I expected it to work. Maybe my expectations are wrong?
I expect:
What I get:
This is problematic because 1) different format of $pk in list and single instance view means, my directive has to figure out if it was called from a list or single instance view 2) saving to the backend fails, because the content of the _id is gone
I tried with "_id" and "_id.$oid". I even tried without any configuration at all, the result does not change. Is there any way to stop it from deleting the contents of the _id?
I tried the following variants (separately, not together ;-)
angular
.module('client')
.factory('Client', Client)
.factory('TestClient', TestClient)
.factory('Clientsearch', Clientsearch)
.factory('Clientcount', Clientcount)
.factory('Clientpaged', Clientpaged)
.config(config);
config.$inject = ['restmodProvider'];
// this is what i used before the backend started throwing ObjectIDs instead of strings
// variant 0 -> $pk = Objectid, _id is empty :-(
function config(restmodProvider) {
restmodProvider.rebase({
$config: {
primaryKey: '_id'
}
});
}
/*
// variant 1 -> $pk = Objectid, _id is empty :-(
function config(restmodProvider) {
restmodProvider.rebase({
$config: {
primaryKey: '_id.$oid'
}
});
}
// variant 2 -> pushModelBase is not a function - has been renamed to rebase
function config(restmodProvider) {
restmodProvider.pushModelBase(function() {
this.setPrimaryKey('_id');
});
}
// variant 2a -> $pk = Objectid, _id is empty :-(
function config(restmodProvider) {
restmodProvider.rebase(function () {
this.setPrimaryKey('_id.$oid');
});
}
// variant 2b -> $pk = Objectid, _id is empty :-(
function config(restmodProvider) {
restmodProvider.rebase(function () {
this.setPrimaryKey('_id');
});
}
// variant 3a -> $pk = Objectid, _id is empty :-(
function config(restmodProvider) {
restmodProvider.rebase({
$config: {
PRIMARY_KEY: '_id'
}
});
}
// variant 3b -> $pk = Objectid, _id is empty :-(
function config(restmodProvider) {
restmodProvider.rebase({
$config: {
PRIMARY_KEY: '_id.$oid'
}
});
}
*/
lame, this is also stopping me from using angular-restmod
Well, it doesn't exactly stop me, it just leads to byzantine code I could do without. Just out of curiosity did anything you tried change anything on the outcome? What puzzles me most, is the fact, that whatever I tried it always turned out exactly the same.
I opted for js-data-angular
Hi!
I'm stuck on dealing with primary keys delivered from the mongodb based backend.
The keys look like this:
I have tried various mappings, both global and local as mentioned on various parts of the website, issues, etc. But at best I can set $pk to a copy of _id. Savings fails, because _id is empty on PUT.
Thanks!