(creature: InsertCreature)
| 20 | } |
| 21 | |
| 22 | export async function saveCreature(creature: InsertCreature) { |
| 23 | try { |
| 24 | const [newCreature] = await db |
| 25 | .insert(creatures) |
| 26 | .values(creature) |
| 27 | .returning(); |
| 28 | return newCreature; |
| 29 | } catch (error) { |
| 30 | console.error(error); |
| 31 | throw new Error("Failed to save creature"); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | export async function getTenLatestCreatures() { |
| 36 | try { |