Skip to content

Instantly share code, notes, and snippets.

@anomaly44
Created December 30, 2015 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anomaly44/cdaa5e4dbd03e9a8429e to your computer and use it in GitHub Desktop.
Save anomaly44/cdaa5e4dbd03e9a8429e to your computer and use it in GitHub Desktop.
import db from '../db';
export default class Issue {
constructor(data) {
...
}
static insertNewIssue(data) {
// var value = null;
db('issue').insert({
agency_id: data.agencyId,
contact_id: 1,
tree_problem_id: data.id,
address_id: 11,
permission_to_access: data.extra.permission === 'true',
notes: data.extra.notes,
info: 'some info'
}).then((res) => {
return {success: true, result: res};
})
.catch((error) => {
console.log('error inserting new Issue:' + JSON.stringify(error));
return {success: false, result: error};
});
/* console.log(value);
return value;*/
}
}
import Issue from '../../models/Issue';
// this is part of an API the new Promise((resolve, reject) => ... is ok and it works
export default function submitIssue(req) {
return new Promise((resolve,reject) => {
const result = Issue.insertNewIssue(req.body);
console.log(result);
if(result.success) {
resolve(result.result);
} else {
reject(result.result);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment