1.0.95 • Published 3 years ago

fast-furniture-util v1.0.95

Weekly downloads
262
License
ISC
Repository
-
Last release
3 years ago

README

This fast furniture node package constians mongoose driver connection, repositories and models

Install

npm i fast-furniture-util

Usage

import { AzureFunction, Context, HttpRequest } from '@azure/functions'
import FastFurniture from 'fast-furniture-util'
import errorHandler from '../shared/error'
const { connect, SupplierRepository } = FastFurniture

const httpTrigger: AzureFunction = async function (
  context: Context,
  req: HttpRequest
): Promise<void> {
  await connect(process.env.CosmosDBConnectionString) // Set the Cosmos DB Connection String
    .then(async (resp) => {
      let supplier_id = req.query.supplier_id
      const supplierRepo = new SupplierRepository()
      const notes = await supplierRepo.getNotes(supplier_id)

      context.res = {
        body: { notes },
      }

      return context.done()
    })
    .catch((error) => {
      errorHandler(400, error, context)
    })
}

export default httpTrigger

Repositories

1. SupplierRepository

2. ProductRepository

2. NoteRepository

Functions of each Repositories

SupplierRepository

Save Supplier

const supplierRepo = new SupplierRepository()

const payload = {
  supplierId: supplierId,
  name: name,
  defaultShippingTime: defaultShippingTime,
}

let newSupplier = await supplierRepo.save(payload)

Delete Supplier

const supplierRepo = new SupplierRepository()
const supplierModel = await supplierRepo.delete(_id)

Get All Supplier

const supplierRepo = new SupplierRepository()
const suppliers = await supplierRepo.findAll()

Update Supplier

const supplierRepo = new SupplierRepository()

const payload = {
  supplierId: supplierId,
  name: name,
  defaultShippingTime: defaultShippingTime,
}

const supplier = await supplierRepo.update(_id, payload)

Create Note

const supplierRepo = new SupplierRepository()

const payload = {
  title: title,
  note: note,
  user: user,
}

let supplier = await supplierRepo.addNote(supplier_id, payload)

ProductRepository

Save Product

const productRepo = new ProductRepository()

const payload = {
  supplierId: supplierId,
  name: name,
  defaultShippingTime: defaultShippingTime,
}

let newProduct = await productRepo.save(payload)

Delete Product

const productRepo = new ProductRepository()
const product = await productRepo.delete(_id)

Get All Product

const productRepo = new ProductRepository()
const product = await productRepo.findAll()

Update Product

const productRepo = new ProductRepository()

const payload = {
  supplierId: supplierId,
  name: name,
  defaultShippingTime: defaultShippingTime,
}

const product = await productRepo.update(_id, payload)

NoteRepository

Delete Note

const noteRepo = new NoteRepository()
let note = await noteRepo.remove(_id)

Get Notes

const supplierRepo = new SupplierRepository()
const notes = await supplierRepo.getNotes(supplier_id)

Update Note

const noteRepo = new NoteRepository()

const payload = {
  supplier_id: supplier_id,
  title: title,
  note: note,
  user: user,
}

let updatedNote = await noteRepo.update(_id, payload)
1.0.88

3 years ago

1.0.89

3 years ago

1.0.91

3 years ago

1.0.90

3 years ago

1.0.95

3 years ago

1.0.94

3 years ago

1.0.93

3 years ago

1.0.92

3 years ago

1.0.73

3 years ago

1.0.72

3 years ago

1.0.71

3 years ago

1.0.77

3 years ago

1.0.76

3 years ago

1.0.74

3 years ago

1.0.79

3 years ago

1.0.78

3 years ago

1.0.80

3 years ago

1.0.84

3 years ago

1.0.83

3 years ago

1.0.82

3 years ago

1.0.81

3 years ago

1.0.87

3 years ago

1.0.86

3 years ago

1.0.85

3 years ago

1.0.66

3 years ago

1.0.65

3 years ago

1.0.69

3 years ago

1.0.68

3 years ago

1.0.67

3 years ago

1.0.70

3 years ago

1.0.62

3 years ago

1.0.61

3 years ago

1.0.60

3 years ago

1.0.64

3 years ago

1.0.63

3 years ago

1.0.55

3 years ago

1.0.59

3 years ago

1.0.58

3 years ago

1.0.57

3 years ago

1.0.56

3 years ago

1.0.51

3 years ago

1.0.50

3 years ago

1.0.54

3 years ago

1.0.53

3 years ago

1.0.52

3 years ago

1.0.48

3 years ago

1.0.47

3 years ago

1.0.49

3 years ago

1.0.44

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.45

3 years ago

1.0.41

3 years ago

1.0.40

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.3

3 years ago

1.0.286

3 years ago

1.0.285

3 years ago

1.0.281

3 years ago

1.0.283

3 years ago

1.0.27

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.2

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.178

3 years ago

1.0.177

3 years ago

1.0.176

3 years ago

1.0.175

3 years ago

1.0.17

3 years ago

1.0.172

3 years ago

1.0.171

3 years ago

1.0.173

3 years ago

1.0.161

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.11

3 years ago

1.0.12

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago