Gathering detailed insights and metrics for node-red-contrib-cloud-firestore
Gathering detailed insights and metrics for node-red-contrib-cloud-firestore
Gathering detailed insights and metrics for node-red-contrib-cloud-firestore
Gathering detailed insights and metrics for node-red-contrib-cloud-firestore
node-red-contrib-firebase-admin
A node-red module that wraps the server-side admin SDK of firebase, firestore, et.c.
@gogovega/node-red-contrib-cloud-firestore
Node-RED nodes to communicate with Google Cloud Firestore
node-red-contrib-google-cloud
Node-RED nodes for Google Cloud Platform
node-red-contrib-google-cloud-ubos
Node-RED nodes for Google Cloud Platform
Node-RED nodes to handle google cloud firestore read and write operations
npm install node-red-contrib-cloud-firestore
Typescript
Module System
Node Version
NPM Version
HTML (62.96%)
JavaScript (37.04%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
18 Stars
107 Commits
5 Forks
6 Watchers
8 Branches
3 Contributors
Updated on May 16, 2024
Latest Version
3.2.0
Package Id
node-red-contrib-cloud-firestore@3.2.0
Unpacked Size
51.28 kB
Size
13.55 kB
File Count
13
NPM Version
8.19.3
Node Version
16.19.1
Published on
Apr 02, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
Node-RED nodes to handle google cloud firestore read and write operations.
For any assistance, contributions or stars, visit the repo.
Install from the palette manager
node-red-contrib-cloud-firestore
Install from npm
npm install node-red-contrib-cloud-firestore
A configuration property under either Read or Write nodes that
initializes a firebase app taking in a name and the json contents of
your apps service account credentials which can be generated under
Project settings > service accounts > Firebase Admin SDK
.
Node fetches data from a referenced collection, subcollection or document.
Configurations can be made within the node or on the msg.firestore
property:
collection
: [string] The collection or subCollection in referencedocument
: [string] The document reference under the defined collectionrealtime
: [boolean] telling the node to listen for live updates or not (false by default)group
: [boolean] fetch all documents under collections with the above supplied collection name (false by default)query
: [array<object>] an array of objects defining query methods to apply to the readdisableHandler
: [boolean] disables the default snapshot handler, returning a built query reference as the payload (false by default)Response data from the operation is output through the msg.payload
property
To perform dynamic queries with the read node through input, you need to supply an array of objects on the msg.firestore.query
property in the order they will be chained
with the query method as the only property and it's value being an array of arguments, or a single string value as show below.
1{ 2 query : [ 3 {where: ["state", "==", "CA"]}, 4 {where: ["population", "<", 1000000]} 5 ] 6} 7 8// reference.where("state", "==", "CA").where("population", "<", 1000000)
1{ 2 query : [ 3 {orderBy: "name"}, 4 {limit: 2} 5 ] 6} 7 8// reference.orderBy("name").limit(2)
1{ 2 query : [ 3 {where: ["population", ">", 100000]}, 4 {orderBy: ["population", "asc"]}, 5 {limit: 2} 6 ] 7} 8 9// reference.where("population", ">", 100000).orderBy("population", "asc").limit(2)
1{ 2 query : [ 3 {orderBy: "population"}, 4 {startAt: 100000}, 5 {endAt: 1000000} 6 ] 7} 8 9// reference.orderBy("population").startAt(100000).endAt(1000000)
You can also write your own snapshot handler under the other settings accordion. The editor is similar to the core function node & but supports
the following global objects: config
(the nodes settings), snap
(query snapshot), util
(nodejs), msg
, context
, RED.util
& console
.
The Promise
, Buffer
and Date
objects are also supported.
The
snap
object contains the resulting query snapshot.
Do remember that what you return
will then be sent as the output payload.
The following example returns an array of objects, while logging to the cmd console
1const docs = []; 2let added = context.flow.get('added'); 3 4snap.docChanges().forEach(change => { 5 docs.push(change.doc.data()); 6 if (change.type === 'added') { 7 added++; 8 console.log('Added: ', change.doc.data()); 9 } 10 if (change.type === 'modified') { 11 console.log('Modified: ', change.doc.data()); 12 } 13 if (change.type === 'removed') { 14 console.log('Removed: ', change.doc.data()); 15} 16}); 17 18context.flow.set('added', added); 19return docs;
Additionally, you can also save your snippets into the snippet library by giving it a file name and clicking the Save to Library
button
If you intend on passing in dynamic configurations from an upstream node while still having realtime enabled, the node will not have your upstream values recorded during the next restart. This could result in some unexpected outcomes.
A way around this would be for the node to store your most recent settings from the interface / upstream nodes into node-red's provided storage mechanism.
To enable this workaround in the node, you'll have to change your instances default storage module from memory
to localfilesystem
in your settings.js
file. Read more on this here
Node performs write operations to the referenced collection, subCollection or document.
Configurations made from within the node or on the msg.firestore
property:
operation
: [string] Write operation to perform, either add
, set
, update
or delete
collection
: [string] collection or subCollection reference to write to.document
: [string] document reference to write to (optional for add
operations)options
: [object] additional options passed to firebase (currently
specific to set
operations)Due to the nature of Cloud firestore's implementation, some actions need special handling.
Arrays
To perform array updates, you'll
need to wrap your elements in an object with the _arrayUnion
or _arrayRemove
property to add or remove elements respectively within an array
1msg.payload = { 2 animals: { 3 _arrayUnion: 'goats' 4 }, 5 farmers: { 6 _arrayRemove: {name: "John Doe"} 7 } 8}
becomes:
1msg.payload = { 2 animals: firestore.FieldValue.arrayUnion("goats"), 3 farmers: firestore.FieldValue.arrayRemove({name: "John Doe"}) 4}
GeoPoints
Objects within the payload received by the Write Node containing a _lat
and _lng
property will be replaced with the appropriate GeoPoint class
1msg.payload = { 2 farm:{ 3 location: { 4 _lat: -1.232134, 5 _lng: 36.123131 6 }, 7 fence: [ 8 {_lat: -1.433434, _lng: 35.123324}, 9 {_lat: -1.673214, _lng: 36.126541}, 10 {_lat: -1.334124, _lng: 34.342131} 11 ] 12 } 13}
becomes:
1msg.payload = { 2 farm: { 3 location: new firestore.GeoPoint(-1.232134, 36.123131), 4 fence: [ 5 new firestore.GeoPoint(-1.433434, 35.123324), 6 new firestore.GeoPoint(-1.673214, 36.126541), 7 new firestore.GeoPoint(-1.334124, 34.342131) 8 ] 9 } 10}
Server Timestamp
Properties with the _serverTimestamp
string value will be replace with the appropriate serverTimestamp sentinel
1msg.payload = { 2 time: '_serverTimestamp' 3}
becomes:
1msg.payload = { 2 time: firestore.FieldValue.serverTimestamp() 3}
Increment
Properties with the _increment
string value will be replaced with the appropriate increment sentinel
1msg.payload = { 2 itemCount: { 3 '_increment': 30 4 } 5}
becomes:
1msg.payload = { 2 itemCount: firestore.FieldValue.increment(30) 3}
Delete
Properties with the _delete
string value will be replaced with the appropriate delete sentinel
1msg.payload = { 2 unwantedField: '_delete' 3}
becomes:
1msg.payload = { 2 unwantedField: firestore.FieldValue.delete() 3}
Both the read & write nodes support mustache templating on the collection
& document
properties, which allows you to
cherry pick your collection / document properties directly from the msg
object.
For example, setting the collection field to {{col}}
with a message object like
1msg = { 2 col: "users" 3}
will have the corresponding node run operations against the users
collection.
Both the read & write nodes can expose a firebase
object that contains the current app instance and a reference
to the firebase admin sdk, which allows you to extend the node to your liking. Simply enable the eject property in the ui / via
an upstream input.
1// upstream input / via the ui 2msg.firestore = { 3 eject: true 4}; 5 6// output 7msg.firebase = { 8 "app": "...", // current firebase instance 9 "admin": "...", // firebase admin sdk 10};
No vulnerabilities found.
Reason
no vulnerabilities detected
Reason
tokens are read-only in GitHub workflows
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
all dependencies are pinned
Details
Reason
no binaries found in the repo
Reason
update tool detected
Details
Reason
GitHub code reviews found for 9 commits out of the last 30 -- score normalized to 3
Details
Reason
0 commit(s) out of 30 and 0 issue activity out of 30 found in the last 90 days -- score normalized to 0
Reason
no badge detected
Reason
security policy file not detected
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Score
Last Scanned on 2022-08-15
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More