1.0.95 • Published 4 years ago

fast-furniture-util v1.0.95

Weekly downloads
262
License
ISC
Repository
-
Last release
4 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

4 years ago

1.0.89

4 years ago

1.0.91

4 years ago

1.0.90

4 years ago

1.0.95

4 years ago

1.0.94

4 years ago

1.0.93

4 years ago

1.0.92

4 years ago

1.0.73

4 years ago

1.0.72

4 years ago

1.0.71

4 years ago

1.0.77

4 years ago

1.0.76

4 years ago

1.0.74

4 years ago

1.0.79

4 years ago

1.0.78

4 years ago

1.0.80

4 years ago

1.0.84

4 years ago

1.0.83

4 years ago

1.0.82

4 years ago

1.0.81

4 years ago

1.0.87

4 years ago

1.0.86

4 years ago

1.0.85

4 years ago

1.0.66

4 years ago

1.0.65

4 years ago

1.0.69

4 years ago

1.0.68

4 years ago

1.0.67

4 years ago

1.0.70

4 years ago

1.0.62

4 years ago

1.0.61

4 years ago

1.0.60

4 years ago

1.0.64

4 years ago

1.0.63

4 years ago

1.0.55

4 years ago

1.0.59

4 years ago

1.0.58

4 years ago

1.0.57

4 years ago

1.0.56

4 years ago

1.0.51

4 years ago

1.0.50

4 years ago

1.0.54

4 years ago

1.0.53

4 years ago

1.0.52

4 years ago

1.0.48

4 years ago

1.0.47

4 years ago

1.0.49

4 years ago

1.0.44

4 years ago

1.0.43

4 years ago

1.0.42

4 years ago

1.0.45

4 years ago

1.0.41

4 years ago

1.0.40

4 years ago

1.0.39

4 years ago

1.0.38

4 years ago

1.0.37

4 years ago

1.0.36

4 years ago

1.0.35

4 years ago

1.0.34

4 years ago

1.0.32

5 years ago

1.0.31

5 years ago

1.0.3

5 years ago

1.0.286

5 years ago

1.0.285

5 years ago

1.0.281

5 years ago

1.0.283

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.2

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.178

5 years ago

1.0.177

5 years ago

1.0.176

5 years ago

1.0.175

5 years ago

1.0.17

5 years ago

1.0.172

5 years ago

1.0.171

5 years ago

1.0.173

5 years ago

1.0.161

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.11

5 years ago

1.0.12

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago