1

I am using the limit child nodes extension to limit a node to 3 children with a structure like this successfully:

{
  "-LqRtMWFDSO3QRJDYA39" : {
    "r" : 0.84,
    "s" : "Mango"
  },
  "-LshaeOZsIRC80q_n4Kl" : {
    "r" : 0.49,
    "s" : "Strawberry"
  },
  "-Ltf2gql89DkVm--xLr3" : {
    "r" : 0.44,
    "s" : "Cheese"
  }
}

Is it possible to use the extension with a structure like so:

{
  "34DAvOOUO7N7vp28NtkdAAZp5vD3" : {
    "-Lshag6VI55LMps7Fe0G" : {
      "post" : true,
      "t" : "Brando"
    }
  },
  "35DDKxWrc8c1yERPf2QAYvRPAUb2" : {
    "-LocHP4oF6NzmS67yW8r" : {
      "post" : true,
      "t" : "Abby"
    },
    "-LscHPsdF6NzmE47sdD3r" : {
      "post" : true,
      "t" : "Abby "
    }
  }
}

I need to limit user's notifications to 15 nodes only, but without knowing the second child when specifying the path I cannot do this without something similar to a cloud function wildcard parameter.

I appreciate the help, cheers!

robsiemb
  • 6,157
  • 7
  • 32
  • 46
hugger
  • 426
  • 4
  • 19

1 Answers1

1

Yes, you can do this.

Since this extension is, in effect, just a cloud function, you can actually use the wildcard format in the NODE_PATH parameter (really, just an environment variable that the cloud function is configured with, as well as its trigger configuration).

Lets say all these items are in a top level node, 'notifications'.

Then you could set the parameter to be:

notifications/{topId}

Which would create the extension's function as a RTDB onCreate method triggering at:

notifications/{topId}/{messageid}

And thus clean up the set of notifications 2 levels deep.

robsiemb
  • 6,157
  • 7
  • 32
  • 46