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.
29 lines
915 B
TypeScript
29 lines
915 B
TypeScript
import type { CloudProviderCredential, CloudProviderName } from 'insomnia-data';
|
|
import { database as db, models } from 'insomnia-data';
|
|
|
|
const { type } = models.cloudCredential;
|
|
|
|
export function create(patch: Partial<CloudProviderCredential> = {}) {
|
|
return db.docCreate<CloudProviderCredential>(type, patch);
|
|
}
|
|
|
|
export async function getById(id: string) {
|
|
return db.findOne<CloudProviderCredential>(type, { _id: id });
|
|
}
|
|
|
|
export function update(credential: CloudProviderCredential, patch: Partial<CloudProviderCredential>) {
|
|
return db.docUpdate<CloudProviderCredential>(credential, patch);
|
|
}
|
|
|
|
export function remove(credential: CloudProviderCredential) {
|
|
return db.remove(credential);
|
|
}
|
|
|
|
export function getByName(name: string, provider: CloudProviderName) {
|
|
return db.find<CloudProviderCredential>(type, { name, provider });
|
|
}
|
|
|
|
export function all() {
|
|
return db.find<CloudProviderCredential>(type);
|
|
}
|