mirror of
https://github.com/Kong/insomnia.git
synced 2026-06-03 13:47:23 -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.
33 lines
908 B
TypeScript
33 lines
908 B
TypeScript
import type { ClientCertificate } from 'insomnia-data';
|
|
import { database as db, models } from 'insomnia-data';
|
|
|
|
const { type } = models.clientCertificate;
|
|
|
|
export function create(patch: Partial<ClientCertificate> = {}) {
|
|
if (!patch.parentId) {
|
|
throw new Error('New ClientCertificate missing `parentId`: ' + JSON.stringify(patch));
|
|
}
|
|
|
|
return db.docCreate<ClientCertificate>(type, patch);
|
|
}
|
|
|
|
export function update(cert: ClientCertificate, patch: Partial<ClientCertificate> = {}) {
|
|
return db.docUpdate<ClientCertificate>(cert, patch);
|
|
}
|
|
|
|
export function getById(id: string) {
|
|
return db.findOne<ClientCertificate>(type, { _id: id });
|
|
}
|
|
|
|
export function findByParentId(parentId: string) {
|
|
return db.find<ClientCertificate>(type, { parentId });
|
|
}
|
|
|
|
export function remove(cert: ClientCertificate) {
|
|
return db.remove(cert);
|
|
}
|
|
|
|
export function all() {
|
|
return db.find<ClientCertificate>(type);
|
|
}
|