mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
5d5d6eecc4
* Basic import summary * Started (broken)
36 lines
643 B
JavaScript
36 lines
643 B
JavaScript
import * as db from '../common/database';
|
|
|
|
export const name = 'Stats';
|
|
export const type = 'Stats';
|
|
export const prefix = 'sta';
|
|
|
|
export function init () {
|
|
return {
|
|
lastLaunch: Date.now(),
|
|
lastVersion: null,
|
|
launches: 0
|
|
};
|
|
}
|
|
|
|
export function migrate (doc) {
|
|
return doc;
|
|
}
|
|
|
|
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];
|
|
}
|
|
}
|