1.0.27 • Published 3 years ago

tt-firestore-utilities v1.0.27

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

Trooptravel Firestore Utilities

  • A few operational methods to manage collections and docments in firestore according to the trooptravel policy
  • Also, consosts of a TT Global functions module to centralize general global functions used accross projects

Installing

Using npm:

# install
$ npm install tt-firestore-utilities

#update
$ npm i tt-firestore-utilities@latest

Firestore Operations

In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with require() use the following approach:

const { store, fsUtils, ttGFuncs } = require('tt-firestore-utilities')

// fsStoreClient = store // use the client for your own operations

const collection_path = '/clients/CLIENT_ID/meetings/'

async function getdocet(){
    let doc = await fsUtils.fs_get_document(collection_path, 'TRIP_ID')
    // console.log(doc)

    let policy = await ttGFuncs.getTravelPolicy('CLIENT_ID', 'TRIP_ID', 'DESTINATOIN_ID')
    // console.log(policy)
}

getdocet()

Notes:

Compulsory env variables that need to be specified for fsUtils:

  • "FS_UTILS_FS_PROJECT_ID": project id of firestire db to access

Compulsory env variables that need to be specified for fsUtils when running locally OR when using cross project firestore database:

  • "FS_UTILS_KEYFILEPATH": (path to service account json file) when in development
  • "FS_UTILS_DB_URL" : state firebase init's db url

Compulsory env variables that need to be specified for ttGFuncs:

  • FS_UTILS_MYSQL_HOST
  • FS_UTILS_MYSQL_USR
  • FS_UTILS_MYSQL_DB
  • FS_UTILS_MYSQL_PASS

Compulsory env variables that need to be specified for ttGFuncs.fs_delete_collection():

  • "FS_UTILS_TOKEN": project token to be used in shell command

Global Functions

Global functions include:

  • getTravelPolicy
  • getDestinationCoreData
  • get_city_cap
  • getTripTravellerCount
  • calcPointDistance
  • generateRandomId
const { ttGFuncs } = require('tt-firestore-utilities')
ttGFuncs.generateRandomId()
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.22

4 years ago

1.0.21

4 years ago

1.0.19

4 years ago

1.0.20

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago