(id, options = {})
| 60 | |
| 61 | // Find a single record by ID. |
| 62 | static async find(id, options = {}) { |
| 63 | const record = await this.findBy( |
| 64 | { |
| 65 | [this.primaryKey]: id, |
| 66 | ...(options.where || {}), |
| 67 | }, |
| 68 | options, |
| 69 | ) |
| 70 | if (record === null) { |
| 71 | throw new Errors.RedwoodRecordNotFoundError(this.name) |
| 72 | } |
| 73 | |
| 74 | return record |
| 75 | } |
| 76 | |
| 77 | // Returns the first record matching the given `where`, otherwise first in the |
| 78 | // whole table (whatever the DB determines is the first record) |