Comments (7)
Hi I made a quick work around function from the SDK to let this extension work on javascript Firebase functions.
const uuidv4 = require('uuid/v4');
const admin = require('firebase-admin');
const functions = require('firebase-functions');
exports.test = functions.https.onCall(async (data, context) => {
return await increment('visits', 'pages/clicks/test', 1);
});
function increment(field, path, val) {
const db = admin.firestore();
const increment = admin.firestore.FieldValue.increment(val);
const update = field.split(".").reverse().reduce((value, name) => ({[name]: value}), increment);
return doc.collection('_counter_shards_').doc(uuidv4()).set(update, {merge: true});
}
It may not be the best solution yet but works.
from extensions.
XFN Team: Would this be an additional "client" in the project, or would it be appropriate to adapt the web script to work in a Node environment?
from extensions.
Duplicate: #55
from extensions.
I think it would be better to adapt the web script to work in a Node environment.
I have tested the above code, and it triggers the aggregation function every time the "test" onCall function is called.
from extensions.
Won't increment provided by admin sdk work for distributed counter tasks?
from extensions.
@voxelbusters FieldValue.increment
is the right thing for incrementing a value, but it doesn't solve the underlying problem that a Firestore document can only be updated about once per second. More info here.
from extensions.
We're not planning an official implementation for any other clients at this time, and we've changed the name of the "Web Client SDK" to "client sample" to try to make that a little more clear.
The typescript sample implementation is a good starting place for a node.js implementation of the counter.
In the future, I'd like to see how much of this logic we can move off of the client and into something like a callable function that's installed by the extension itself.
from extensions.
Related Issues (20)
- [firestore-bigquery-export]: Wrong value in description for maximum dispatches per second.
- 🐛 [firestore-bigquery-export] schema-views script doesn't work against multiple schema files
- Typo in `README.md` for `storage-resize-images` extension
- 🐛 [firestore-bigquery-export] multi-db selection isn't working for Firestore triggers HOT 1
- time partition not working for firebase extension(0.1.49) HOT 4
- 🐛 [Stream Firestore to BigQuery] fs-bq-import-collection doesn't recognize partitioned field HOT 1
- 🐛 [Stream-Firestore-BigQuery] Import existing Firestore documents into BigQuery HOT 2
- 🐛 [firestore-send-email] Email status SUCCESS but not delivered
- [firestore-translate-text] Source text is translated from Latin and not English HOT 2
- firefox
- [firestore-send-email] Email templates stopped working yesterday. HOT 2
- 🐛 [Vector Search with Firestore] Error creating firestore Vector index. backfillTrigger() fail HOT 25
- 🐛 [firestore-vector-search] model: 'text-multilingual-embedding-002' HOT 1
- 🐛 Stream Firestore to BigQuery - disable changelog HOT 1
- 🐛 [storage-resize-images] Extension crops the image with default settings. HOT 2
- 🐛 [storage-resize-images] Console error when trying to use the extension
- 🐛 [firestore-translate-text] Error on updating Extension
- 🐛 [EXTENSION_NAME_HERE] allow schedule email
- 🐛 [firestore-translate-text] can not translate array field
- 🐛 [firestore-bigquery-export] Task size too large errors occuring even with EXCLUDE_OLD_DATA set to yes/true
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from extensions.