insomnia/app/backend/database/models/settings.js

35 lines
718 B
JavaScript
Raw Normal View History

import * as db from '../index';
2016-09-21 20:32:45 +00:00
export const type = 'Settings';
export const prefix = 'set';
export function init () {
return db.initModel({
showPasswords: true,
useBulkHeaderEditor: false,
followRedirects: false,
editorFontSize: 12,
editorLineWrapping: true,
httpProxy: '',
httpsProxy: '',
timeout: 0,
validateSSL: true
});
}
2016-09-21 20:32:45 +00:00
export async function create (patch = {}) {
return db.docCreate(type, patch);
}
2016-09-21 20:32:45 +00:00
export async function update (settings, patch) {
2016-09-21 20:32:45 +00:00
return db.docUpdate(settings, patch);
}
2016-09-21 20:32:45 +00:00
export async function getOrCreate () {
const results = await db.all(type);
if (results.length === 0) {
return await create();
} else {
return results[0];
}
}