insomnia/app/models/request-meta.js
Gregory Schier c4b920c7e9 Slightly smarter preview mode selection (#125)
* Slightly smarter preview mode selection

* Tweak autocomplete stuff a bit

* Switched variable editor to <select>

* Reduced lag on nunjucks tags
2017-03-30 11:52:07 -07:00

41 lines
844 B
JavaScript

import * as db from '../common/database';
import {PREVIEW_MODE_FRIENDLY} from '../common/constants';
export const name = 'Request Meta';
export const type = 'RequestMeta';
export const prefix = 'reqm';
export const canDuplicate = true;
export function init () {
return {
parentId: null,
previewMode: PREVIEW_MODE_FRIENDLY,
responseFilter: '',
activeResponseId: null
};
}
export function migrate (doc) {
return doc;
}
export function create (patch = {}) {
if (!patch.parentId) {
throw new Error('New RequestMeta missing `parentId`', patch);
}
return db.docCreate(type, patch);
}
export function update (requestMeta, patch) {
return db.docUpdate(requestMeta, patch);
}
export function getByParentId (parentId) {
return db.getWhere(type, {parentId});
}
export function all () {
return db.all(type);
}