mirror of
https://github.com/Kong/insomnia.git
synced 2026-04-30 02:52:57 -04:00
35 lines
833 B
TypeScript
35 lines
833 B
TypeScript
import {
|
|
type BaseGitCredentialsV2,
|
|
database as db,
|
|
type GitCredentials,
|
|
type GitCredentialsV2,
|
|
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, {});
|
|
}
|