insomnia/app/backend/database/models/response.js
Gregory Schier 318c35c2cb Move a bunch of stuff to async/await (#39)
* 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
2016-10-02 13:57:00 -07:00

32 lines
666 B
JavaScript

import * as db from '../index';
export const type = 'Response';
export const prefix = 'res';
export function init () {
return db.initModel({
statusCode: 0,
statusMessage: '',
contentType: 'text/plain',
url: '',
bytesRead: 0,
elapsedTime: 0,
headers: [],
cookies: [],
body: '',
error: ''
})
}
export function create (patch = {}) {
if (!patch.parentId) {
throw new Error('New Response missing `parentId`');
}
db.removeBulkSilently(type, {parentId: patch.parentId});
return db.docCreate(type, patch);
}
export function getLatestByParentId (parentId) {
return db.getMostRecentlyModified(type, {parentId});
}