tt-firestore-utilities v1.0.27
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()
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago