Loopback - GET model using custom String ID from MongoDB -
i'm developing api loopback, worked fine until decided change ids of documents in database. don't want them auto generated.
now i'm setting id myself. "unknown id" 404, whenever hit endpoint: get properties/{id}
how can use custom ids loopback , mongodb?
whenever hit endpoint: http://localhost:5000/api/properties/20020705171616489678000000
error:
{ "error": { "name": "error", "status": 404, "message": "unknown \"property\" id \"20020705171616489678000000\".", "statuscode": 404, "code": "model_not_found" } }
this model.json, in case...
{ "name": "property", "plural": "properties", "base": "persistedmodel", "idinjection": false, "options": { "validateupsert": true }, "properties": { "id": {"id": true, "type": "string", "generated": false}, "photos": { "type": [ "string" ] }, "propertytype": { "type": "string", "required": true }, "internalid": { "type": "string", "required": true }, "flexcode": { "type": "string", "required": true } }, "validations": [], "relations": {}, "acls": [], "methods": [] }
your model setup (with idinjection: true
or false
) did work when tried postgresql db setup text id field smaller numbers.
running loopback application debug=loopback:connector:* node .
outputs database queries being run in terminal - tried id value trying , parameter value [2.002070517161649e+25]
, size of number issue.
you try raising bug in loopback, js horrible @ dealing large numbers may better off not using such large numbers identifiers anyway.
it work if id alphanumeric string on 16 characters there might work around (use objectid?), depending on trying achieve.
Comments
Post a Comment