Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/api/profile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ function configure (app, wares, ctx) {
res.json(created.ops);
console.log('Profile created', created);
}

});
});

Expand Down
4 changes: 4 additions & 0 deletions lib/authorization/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ function init (env, ctx) {
obj.created_at = (new Date()).toISOString();
}
collection.insert(obj, function (err, doc) {
if (err != null && err.message) {
console.log('Data insertion error', err.message);
return;
}
storage.reload(function loaded() {
fn(null, doc.ops);
});
Expand Down
4 changes: 4 additions & 0 deletions lib/server/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ function storage (env, ctx) {
function create (obj, fn) {
obj.created_at = (new Date( )).toISOString( );
api().insert(obj, function (err, doc) {
if (err != null && err.message) {
console.log('Activity data insertion error', err.message);
return;
}
fn(null, doc.ops);
});
}
Expand Down
4 changes: 4 additions & 0 deletions lib/server/devicestatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ function storage (collection, ctx) {
obj.created_at = (new Date()).toISOString();
}
api().insert(obj, function (err, doc) {
if (err != null && err.message) {
console.log('Error inserting the device status object', err.message);
return;
}
fn(null, doc.ops);
ctx.bus.emit('data-received');
});
Expand Down
4 changes: 4 additions & 0 deletions lib/server/food.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ function storage (env, ctx) {
function create (obj, fn) {
obj.created_at = (new Date( )).toISOString( );
api().insert(obj, function (err, doc) {
if (err != null && err.message) {
console.log('Data insertion error', err.message);
return;
}
fn(null, doc.ops);
});
}
Expand Down
12 changes: 12 additions & 0 deletions lib/server/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ function init (env, ctx, server) {
// if not found create new record
console.log(LOG_DEDUP + 'Adding new record');
ctx.store.collection(collection).insert(data.data, function insertResult (err, doc) {
if (err != null && err.message) {
console.log('Data insertion error', err.message);
return;
}
if (callback) {
callback(doc.ops);
}
Expand Down Expand Up @@ -367,13 +371,21 @@ function init (env, ctx, server) {
}
});
ctx.store.collection(collection).insert(data.data, function insertResult (err, doc) {
if (err != null && err.message) {
console.log('Data insertion error', err.message);
return;
}
if (callback) {
callback(doc.ops);
}
ctx.bus.emit('data-received');
});
} else {
ctx.store.collection(collection).insert(data.data, function insertResult (err, doc) {
if (err != null && err.message) {
console.log('Data insertion error', err.message);
return;
}
if (callback) {
callback(doc.ops);
}
Expand Down