import type { ProtoFile } from 'insomnia-data'; import { database as db, models } from 'insomnia-data'; const { type } = models.protoFile; export function create(patch: Partial = {}) { if (!patch.parentId) { throw new Error('New ProtoFile missing `parentId`'); } return db.docCreate(type, patch); } export function remove(protoFile: ProtoFile) { return db.remove(protoFile); } export function update(protoFile: ProtoFile, patch: Partial = {}) { return db.docUpdate(protoFile, patch); } export function getById(_id: string) { return db.findOne(type, { _id }); } export function getByParentId(parentId: string) { return db.findOne(type, { parentId }); } export function findByParentId(parentId: string) { return db.find(type, { parentId }); } export function all() { return db.find(type); }