From 10eb82c7c00a0a1a75528644fbfbe108a769207f Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Fri, 11 Nov 2022 22:57:19 +0530 Subject: serving created invoices as both HTML and JSON --- invoice/db_actions.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'invoice/db_actions.go') diff --git a/invoice/db_actions.go b/invoice/db_actions.go index a4880fa..0cbeec1 100644 --- a/invoice/db_actions.go +++ b/invoice/db_actions.go @@ -117,3 +117,15 @@ func getTransports(filter bson.M) ([]Transport, error) { err = cursor.All(context.TODO(), &transports) return transports, err } + +func getInvoiceByNumber(invoiceNumber int) (Invoice, error) { + var invoice Invoice + err := db.Collection("Invoices").FindOne(context.TODO(), bson.M{"InvoiceNumber": invoiceNumber}).Decode(&invoice) + return invoice, err +} + +func getInvoiceById(invoiceId primitive.ObjectID) (Invoice, error) { + var invoice Invoice + err := db.Collection("Invoices").FindOne(context.TODO(), bson.M{"_id": invoiceId}).Decode(&invoice) + return invoice, err +} -- cgit v1.2.3