mirror of
https://github.com/Kong/insomnia.git
synced 2026-06-04 06:10:24 -04:00
Move insomnia-data models, services, database code, and common utilities into a dedicated workspace package. Update consumers to import from the new package entrypoints and declare workspace dependencies for the extracted package.
29 lines
726 B
TypeScript
29 lines
726 B
TypeScript
import type { UnitTest } from 'insomnia-data';
|
|
import { database as db, models } from 'insomnia-data';
|
|
|
|
const { type } = models.unitTest;
|
|
|
|
export function create(patch: Partial<UnitTest> = {}) {
|
|
if (!patch.parentId) {
|
|
throw new Error('New UnitTest missing `parentId` ' + JSON.stringify(patch));
|
|
}
|
|
|
|
return db.docCreate<UnitTest>(type, patch);
|
|
}
|
|
|
|
export function remove(unitTest: UnitTest) {
|
|
return db.remove(unitTest);
|
|
}
|
|
|
|
export function update(unitTest: UnitTest, patch: Partial<UnitTest> = {}) {
|
|
return db.docUpdate<UnitTest>(unitTest, patch);
|
|
}
|
|
|
|
export function getByParentId(parentId: string) {
|
|
return db.findOne<UnitTest>(type, { parentId });
|
|
}
|
|
|
|
export function all() {
|
|
return db.find<UnitTest>(type);
|
|
}
|