mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
318c35c2cb
* Some minor implementations * Some more * Lots more * Removed 'backend' alias * removed all promises * Removed a bunch of module exports stuff * Some morE' * Fix * custom DNS * Tests for DNS * bug fix * Some small adjustments * Small stuff
32 lines
583 B
JavaScript
32 lines
583 B
JavaScript
'use strict';
|
|
|
|
const db = require('../index');
|
|
|
|
export const type = 'Stats';
|
|
export const prefix = 'sta';
|
|
export function init () {
|
|
return db.initModel({
|
|
lastLaunch: Date.now(),
|
|
lastVersion: null,
|
|
launches: 0
|
|
});
|
|
}
|
|
|
|
export function create (patch = {}) {
|
|
return db.docCreate(type, patch);
|
|
}
|
|
|
|
export async function update (patch) {
|
|
const stats = await get();
|
|
return db.docUpdate(stats, patch);
|
|
}
|
|
|
|
export async function get () {
|
|
const results = await db.all(type);
|
|
if (results.length === 0) {
|
|
return await create();
|
|
} else {
|
|
return results[0];
|
|
}
|
|
}
|