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.
30 lines
844 B
TypeScript
30 lines
844 B
TypeScript
import type { BaseGitCredentialsV2, GitCredentials, GitCredentialsV2 } from 'insomnia-data';
|
|
import { database as db, models } from 'insomnia-data';
|
|
|
|
const { type } = models.gitCredentials;
|
|
|
|
export function create(patch: BaseGitCredentialsV2) {
|
|
return db.docCreate<GitCredentialsV2>(type, patch);
|
|
}
|
|
|
|
export async function getById(id: string) {
|
|
const doc = await db.findOne<GitCredentials>(type, { _id: id });
|
|
return doc ?? null;
|
|
}
|
|
|
|
export function update(credentials: GitCredentialsV2, patch: Partial<GitCredentialsV2>) {
|
|
return db.docUpdate<GitCredentialsV2>(credentials, patch);
|
|
}
|
|
|
|
export function remove(credentials: GitCredentials) {
|
|
return db.remove(credentials);
|
|
}
|
|
|
|
export async function all() {
|
|
return await db.find<GitCredentials>(type);
|
|
}
|
|
|
|
export function removeAll() {
|
|
return db.removeWhere<GitCredentials>(type, {});
|
|
}
|