Extend store API
This commit is contained in:
15
lib/store.js
15
lib/store.js
@ -20,10 +20,16 @@ function list(query, fields) {
|
||||
return r;
|
||||
}
|
||||
|
||||
function listAll(query) {
|
||||
var r = knex.select().from(reports);
|
||||
if (query) return r.where(query);
|
||||
return r;
|
||||
}
|
||||
|
||||
function get(id) {
|
||||
if (!id) return error('No id specified.');
|
||||
|
||||
return knex(reports).where('id', id);
|
||||
return knex(reports).where('id', id).first();
|
||||
}
|
||||
|
||||
function add(data) {
|
||||
@ -45,13 +51,15 @@ function add(data) {
|
||||
preloadedState: data.preloadedState,
|
||||
screenshot: data.screenshot,
|
||||
version: data.version,
|
||||
appId: data.appId,
|
||||
userAgent: data.userAgent,
|
||||
user: data.user,
|
||||
userId: typeof data.user === 'object' ? data.user.id : data.user,
|
||||
instanceId: data.instanceId,
|
||||
meta: data.meta,
|
||||
exception: data.exception
|
||||
exception: data.exception,
|
||||
added: Date.now()
|
||||
};
|
||||
if (data.appId) report.appId = data.appId; // TODO check if the id exists and we have access to link it
|
||||
/*
|
||||
var payload = {
|
||||
id: uuid.v4(),
|
||||
@ -73,6 +81,7 @@ function createStore(options) {
|
||||
|
||||
return {
|
||||
list: list,
|
||||
listAll: listAll,
|
||||
get: get,
|
||||
add: add
|
||||
};
|
||||
|
Reference in New Issue
Block a user