How can I return a record that matches some custom id (not the regular id) from my collection?
// record schema
{
id: 123, // assigned id from mirage
dId: 'DEVICE0001', // device id I want to use to pick
value: 'some content'
}
To select with something like this:
// app/mirage/config.js
this.get("/something/:device_did", function(db, request){
var mid = request.params.device_did;
// select using my device id
return db.devices.firstWhere( { 'dId': did });
});
The API docs only reference a 'find()' function that acts on the id, and a 'where()' that gets an array of records.
Aucun commentaire:
Enregistrer un commentaire