I want to use slugs ( String) instead ObjectIDfor some of the objects subject to REST in Loopback
What the docs say about model identifiers:
By default, if no ID properties are defined, and the idInjection of model parameters is false, LDL automatically adds the id property to the model as follows:
id: {type: Number, generated: true, id: true}
I thought I just needed to specify Stringboth type and generated: falseto avoid this loopback instead ObjectID.
id: { type: String, generated: false, id: true },
-> It didn't work at all
In the code , mongodb.jsI see that regardless of my name idit is wrapped using a ObjectIDfunction that explains the loss of value String.
: generated mongodb, ?
(objectId, , ) , :
id: {
type: String,
objectId: false,
id: true
},
: MongoDB.prototype.create@mongodb.js:155:
var isObjectId = self.getDataSource(model)
.getModelDefinition(model)
.properties[idName]
.objectId;
if (idValue === null) {
delete data[idName];
} else {
var oid = isObjectId ? ObjectID(idValue) : idValue;
data._id = oid;
delete data[idName];
}
save() , / slug REST.
, , - ?
, , , , , StrongLoop , .