Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
firebase-database-pagination
Advanced tools
Allows pagination for the Firebase RTDB.
All the normal methods return an array of DataSnapshot
s.
To paginate over all the keys of a node you can use:
const pagination = require('firebase-database-pagination')
const admin = require('firebase-admin').initializeApp()
const children = await pagination.key(admin.database().ref('node'), 10)
This will fetch all children of node
in batches of 10.
To paginate over keys order by the nodes value you can use:
const pagination = require('firebase-database-pagination')
const admin = require('firebase-admin').initializeApp()
const children = await pagination.value(admin.database().ref('node'), 10)
To paginate over all the keys of a node order by a childs key you can use:
const pagination = require('firebase-database-pagination')
const admin = require('firebase-admin').initializeApp()
const children = await pagination.child(admin.database().ref('node'), 'childKey', 10)
The .key
, .value
and .child
methods have a .transformed
function property which allows each result to be converted to something else if needed.
The transformer
parameter can return a value or a promised value.
const pagination = require('firebase-database-pagination')
const admin = require('firebase-admin').initializeApp()
const values = await pagination.key.transformed(admin.database().ref('node'), 10, nodeChildSnapshot => {
return { key: nodeChildSnapshot.key, value: nodeChildSnapshot.child('count') }
})
// values is an array of { key, count }
const values = await pagination.key.transformed(admin.database().ref('node'), 10, async nodeChildSnapshot => {
return await admin.database().ref('other').child(nodeChildSnapshot.key)
})
// values is an array of DataSnaphots pointing at /other/<nodeChildKey>
All of the methods except a parameter to return a subset of values.
const pagination = require('firebase-database-pagination')
const admin = require('firebase-admin').initializeApp()
// Return all keys where the value is equal to 10
await pagination.value(admin.database().ref('node'), 10, { equalTo: 10 })
// Return all keys where the value is greater then or equal to 10
await pagination.value(admin.database().ref('node'), 10, { startAt: 10 })
// Return all keys where the value is less then or equal to 20
await pagination.value(admin.database().ref('node'), 10, { endAt: 20 })
// Return all keys where the value is greater then or equal to 15 AND less than or equal to 25 (i.e. in the interval [15, 25])
await pagination.value(admin.database().ref('node'), 10, { startAt: 15, endAt: 25 })
FAQs
Pagination for Firebase RTDB
The npm package firebase-database-pagination receives a total of 39 weekly downloads. As such, firebase-database-pagination popularity was classified as not popular.
We found that firebase-database-pagination demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.