Firebase deep increment of a field in a data base

Firebase deep increment of a field in a data base

Content Index :

Firebase deep increment of a field in a data base
Tag : node.js , By : user87225
Date : January 12 2021, 01:40 AM

wish help you to fix your issue I have this structure: Users is a collection, inside there are userIDs docs, each has a user object which contains also an object with a certain nick name . , solved
docRef.update({ ['user.analytics.' + nickID + '.visitors']: admin.firestore.FieldValue.increment(1) });

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to join denormalized data that goes two+ levels deep in Firebase

Tag : firebase , By : fukas78
Date : March 29 2020, 07:55 AM
help you fix your problem See a working example here
The gist of this sort of denormalization is to fetch the users as you grab posts. It's nothing more complex than it sounds. Just go grab them.
<h3>Normalizing user profiles into posts</h3>

<ul ng-controller="ctrl">
    <li ng-repeat="post in posts | orderByPriority" ng-init="user = users.$load(post.user)">
        {{user.name}}: {{post.title}}
var app = angular.module('app', ['firebase']);
var fb = new Firebase(URL);

app.controller('ctrl', function ($scope, $firebase, userCache) {
    $scope.posts = $firebase(fb.child('posts'));
    $scope.users = userCache(fb.child('users'));

app.factory('userCache', function ($firebase) {
    return function (ref) {
        var cachedUsers = {};
        cachedUsers.$load = function (id) {
            if( !cachedUsers.hasOwnProperty(id) ) {
                cachedUsers[id] = $firebase(ref.child(id));
            return cachedUsers[id];
        cachedUsers.$dispose = function () {
            angular.forEach(cachedUsers, function (user) {
        return cachedUsers;

Firebase - Indexing Data Two Levels Deep

Tag : firebase , By : Derek
Date : March 29 2020, 07:55 AM
Does that help I have a Firebase data structure that looks like: , You can specify dynamic .indexOn like this:
    "rules" : {
        "messages" : {
            "$userId": {
                ".indexOn" : ["message", "direction"]

Access to Deep data via Firebase Admin

Tag : javascript , By : Tom
Date : March 29 2020, 07:55 AM
Does that help How Can I Access to Deep data via Firebase Admin? , To get the keyboard children:
const ref = db.ref('keyboards/SecendKeyboard/childs');
ref.on("value", function (snapshot) {
const ref = db.ref('keyboards/SecendKeyboard');
ref.on("value", function (snapshot) {
const ref = db.ref('keyboards');
ref.on("value", function (snapshot) {
    snapshot.forEach(function(childSnapshot) {
        console.log(snapshot.val()); // prints StartKeyboard and SecendKeyboard
        if (snapshot.child("SecendKeyboard").exists()) {

How to target specific field in Firebase / AngularFire when more than 1 level deep

Tag : angularjs , By : kuba53280
Date : March 29 2020, 07:55 AM

Is there any way to auto increment a field in firebase

Tag : javascript , By : Terrence Poon
Date : March 29 2020, 07:55 AM
Any of those help I want to auto increment a stock number for each new item added to the firestore database. (Not using the push() method) , You can do it easily using Cloud Functions
// Change '/COLLECTION/{DOC}' to which document do you want to increment the counter when it's created
exports.counter = functions.firestore.document('/COLLECTION/{DOC}').onCreate((snap, context) => {
  const db = admin.firestore();

  // Change 'counter/ref' to where do you want to increment
  const countRef = db.doc('counter/ref');
  return db.runTransaction(t => {
    return t.get(countRef).then(doc => {
      const counter = (doc.data().counter || 0) + 1;
      t.update(countRef, {counter: counter});

Related Posts Related QUESTIONS :
  • How to get hash value from image using ImageMagick or GraphicsMagick Node.js?
  • How to require dotenv/config file on (before) PM2 starts
  • Node JS Async/Await
  • How to concat chunks of incoming binary into video (webm) file node js?
  • GitLab CI with Postgres ERROR: connect ECONNREFUSED
  • Is it possible to show live data from MongoDB via socket.io?
  • Uploading HDR photo from iPhone to web - GPS data missing
  • Can I run multiple node version on Jenkins?
  • How to set default boolean value in sequelize
  • Cannot read property 'db' of null javascript with parcel
  • using async function into loop with nodejs?
  • How to use keycloak with NestJS properly
  • Changing the title of the header
  • How can i make an horizontal carousel in dialogflow?
  • how to fix the problem when i run any command regarding to npm it shows error
  • node.js - how to check/get ssl certificate expiry date
  • How to show base64 image in react?
  • Error while pushing to Heroku: Cannot find module 'node-linux-x64/package.json'
  • Adding title element to paperjs SVG (using node.js)
  • Wait for firestore queries to finish before return a cloud function response
  • How to upload files larger than 10mb via google cloud http functions. ? Any alternative options?
  • How to use the NODE_OPTIONS environment variable to set the max_old_space_size globally in Windows?
  • Is nodejs representing Reactor or Proactor design pattern?
  • How to reference generated Prisma schema in my schema.graphql file for a query that filters by id
  • Cant figure out what is wrong with my models
  • npm ERR! EPROTO: protocol error, symlink '../@babel/parser/bin/babel-parser.js' -> '/home/vagrant/code/proadco.test/n
  • express-session - the difference between session id and connect.sid?
  • How do you run this list of command that come from a book Eloquent Javascript Node.js
  • how to convert from import to require in nodejs
  • POST request returns undefined
  • How to read large json file in node js?
  • AWS Lambda function written in nodejs is not updating my DynamoDB
  • Best way to define a Map Object in GraphQL Schema?
  • bigchaindb-driver not found in node_modules?
  • Upgrading yarn in root directory do not upgrade Workspace dependencies
  • How can I redirect all clients to another page with socket.io?
  • How is `cluster` and `worker_threads` work in Node.js?
  • AWS Lambda - Not able to a access JS file bundled in Layer (Node.js)
  • How to connect AWS Bitnami Certified Kafka AMI with Elastic Beanstalk nodejs environment using kafka-node
  • Define Shortcut Keys by user (add or edit by user in web app)?
  • 'this' in regular function vs fat arrow function in ES6, illustrated with an example of Mongoose
  • Could not find the implementation for builder @angular-devkit/build-angular:dev-server on ng serve command
  • The engine "node" is incompatible with this module
  • fs.readDirSync can't find dir in typescript?
  • Difference between keepAliveTimeout and timeout?
  • Visual Studio Code: "'tslib' cannot be found" error in Angular project
  • Embedding twitter timeline does not render in angular 7
  • Secret environment variables in Cloudbuild (with out files), how?
  • more than one 2dsphere index, not sure which to run geoNear
  • Why only 50 instances working on AWS lambda?
  • VSCode debugging (F5) react app gives SyntaxError: Unexpected identifier
  • How to use sweetalert in nodejs?
  • ng update --all does say 'Repository is not clean' evendought git commit
  • I want to update user profile
  • Uncaught ReferenceError: __webpack_dev_server_client__ is not defined
  • Webpack not being recognized after updates
  • use firebase Storage with Admin sdk node.js
  • If I want my graphql endpoint to be something other than `/graphql`, how do I configure it with the `GraphqlModule`?
  • Node.js JWT token
  • Filtering the user data with the age max and age min while date of birth is present in schema
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com