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)
| 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. |