blob: c6bf4b6ef6b13976350c941be1c704957b482720 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
const { Op } = require("sequelize");
app.post("/invoice", auth, async (req, res) => {
const { invoice } = req.body;
invoice.user_id = req.user.id;
l.info("creating invoice", invoice.text, req.user.username, invoice.network, invoice.amount, invoice.tip, invoice.currency, invoice.rate.toFixed(2));
const exists = await db.Invoice.findOne({
where: {
[Op.or]: {
address: invoice.address || "undefined",
text: invoice.text
}
}
});
res.send(
exists ? await exists.update(invoice) : await db.Invoice.create(invoice)
);
});
|