MCPcopy
hub / github.com/miragejs/miragejs / find

Method find

lib/orm/schema.js:239–255  ·  view source on GitHub ↗

Return one or many models in the database by id. ```js let post = blogPosts.find(1); let posts = blogPosts.find([1, 3, 4]); ``` @method find @param type @param ids @public

(type, ids)

Source from the content-addressed store, hash-verified

237 @public
238 */
239 find(type, ids) {
240 let collection = this.collectionForType(type);
241 let records = collection.find(ids);
242
243 if (Array.isArray(ids)) {
244 assert(
245 records.length === ids.length,
246 `Couldn't find all ${this._container.inflector.pluralize(
247 type
248 )} with ids: (${ids.join(",")}) (found ${
249 records.length
250 } results, but was looking for ${ids.length})`
251 );
252 }
253
254 return this._hydrate(records, dasherize(type));
255 }
256
257 /**
258 Returns the first model in the database that matches the key-value pairs in `attrs`. Note that a string comparison is used.

Callers 15

registerModelMethod · 0.95
isExternalFunction · 0.45
routesFunction · 0.45
routesFunction · 0.45
schema-test.tsFile · 0.45
db-test.tsFile · 0.45
removeMethod · 0.45
isNewMethod · 0.45
reloadMethod · 0.45
disassociateMethod · 0.45

Calls 4

collectionForTypeMethod · 0.95
_hydrateMethod · 0.95
dasherizeFunction · 0.90
assertFunction · 0.85

Tested by 15

serializeFunction · 0.36
savedChildNoParentMethod · 0.36
savedChildNewParentMethod · 0.36
savedChildSavedParentMethod · 0.36
newChildSavedParentMethod · 0.36
savedParentMethod · 0.36
savedChildNoParentMethod · 0.36
savedChildSavedParentMethod · 0.36
newChildSavedParentMethod · 0.36
savedParentMethod · 0.36
savedChildNoParentMethod · 0.36
savedChildSavedParentMethod · 0.36