romainvialard / firebaseapp Goto Github PK
View Code? Open in Web Editor NEWGoogle Apps Script binding for Firebase Realtime Database
License: Apache License 2.0
Google Apps Script binding for Firebase Realtime Database
License: Apache License 2.0
Currently, if you have a key named "error" in Firebase, when fetching it, the lib return an error 200 (Error: 200 - [object Object]).
Hi! I have tried using your library, but it is not found in Google App Script. Library ID has changed? I tried using the MYeP8ZEEt1ylVDxS7uyg9plDOcoke7-2l project key.
Thank you!
Just wondering if you have any plans to get this working for a Firestore database, or any recommendations on how I should approach adapting this to a firestore database?
Hi everyone,
I just tried for the first time to use this library and it returns me this error whenever I try to use ".getAllData(db_path,db_secret)" method. I tried both with secret and without secret key, but it keeps giving me the error.
Is there any way to fix it?
Hello,
I started getting this error last night on a script that had been triggering fine all day. I'm not sure what the issue is, can you please advise? Thanks.
Derrick
I am having trouble and have narrowed down the issue to the auth token generated by .createAuthToken()
.
FirebaseApp.getDatabaseByUrl(fb_URL, service.getAccessToken())
.createAuthToken(Session.getEffectiveUser().getEmail())
When I use the Database Secret it will generate an authentication token that is usable client-side to make calls to Firebase, but for some reason an access token generated by a service account with OAuth2 doesn't make a valid authentication token.
I have also posted an issue here on StackOverflow with my code based on the tutorials mentioned in the readme.
As a side note, I love your work! It has helped me learn a lot about GAS over the years. Thank You!
The latest one as of March 2019
<script src="https://www.gstatic.com/firebasejs/5.9.2/firebase-app.js"></script>I am using your FirebaseApp library as follow:
var r = base.getData("", { orderBy:"code", equalTo: code });
Assuming there are entries with the codes below, instead of valid results, I am getting these ...
var code = "12345"; // no results
var code = "03456"; // Error: Constraint index field must be a JSON primitive
The issue comes from line 249:
if (isNaN(optQueryParameters[key]) && typeof optQueryParameters[key] !== 'boolean') {
Because in both cases the function isNaN() returns false, considering both codes as numbers (that's how isNaN works as I understand), so it won't add the "" around the string value
But in this case the code values are strings with only digits, that can also have leading zeros
Is there a way to fix / workaround this situation?
Thanks in advance
Fausto
p.s.
I did a dirty hack to make it work, but not sure if it's the right approach
I just redefined isNaN as follow:
FirebaseApp.isNaN = function(n) {
return Number(parseFloat(n)) !== n;
};
and it's working that way
Imagine this:
User 1 email address = [email protected]
User 1 escaped email address = johndoefoobarcom
User 2 email address = [email protected]
User 2 escaped email address = johndoefoobarcom
Switched to V8 Runtime and getting a bug where when, requesting to an endpoint which would normally return 'null' the whole script crashes with the 'Error connecting to Google Server'.
Well I loaded the library locally and this fix seems to do the job
baseClass_.getData = function (path, optQueryParameters) {
// Send request
// noinspection JSAnnotator
var [res] = FirebaseApp_._buildAllRequests([
{
method: 'get',
path: path,
optQueryParameters: optQueryParameters,
},
], this);
// Throw error
if (res instanceof Error) {
throw res;
}
if(res){
return res;
}
};
TLDR: dont return anything if the value to be returned is null.
First, just want to say thanks for all of the hard work on this. It works great.
My only concern is when writing data, I would like to have the option to disable overwriting. A good example is if you have a huge amount of data that will not fit in a Google sheet. The initial push to the realtime db works great but if I delete the information in that sheet and create new data in the sheet. I would like to append it to the db without overwriting. Is this possible?
If there is a work around for this already, I apologize.
Looking for a feature to be added. If the pushdata method could optionally push directly into the path.
Currently, if I use the pushdata method it will add a subpath with a unique id under the selected path. It would be great if that object information could be added directly under the specified path instead of creating a subPath with the unique id.
I could loop through to create a record every time but this will be very slow.
This could be useful if I need to add multiple spreadsheets to a single database but do not want to overwrite the information.
Thanks for the great script! I used the library from the Google App Script and it works great!
But one thing I noticed is when calling getAllData, the returned data is not in proper json format. Instead of having colons, it has equal signs.
Here is an example return:
[{-LINN2XT9wdCMEQGhZ9C={firstName=myname, yourSalary=200000, position=ioio, salary=100000}, -LINBdoUX4-s793E-cDW={firstName=abcdsad, position=hahahhahha, salary=1223434}, -LINDhN0TNmOcP6Y6_Qq={firstName=yourname, yourSalary=2000000, position=senior leader}}]
Any clue what went wrong?
When I try to add query parameters to an updateData call, I get the following error:
Error: Querying related parameters not supported on this request type (line 322, file "Code", project "FirebaseApp")
Is Firebase not able to add query parameters to update calls and there is just an error in the documentation? Or is it possible, and there is a bug in the code?
By the way, I love this library. It's power and simplicity have allowed me to build a world of web apps for my employer. Thank you so much for all your hard work.
I was having the same issue as #23 and saw the solution to use limitToFirst & startAt for pagination as per the docs. To use startAt however, you need to use orderBy. Since my data on Firebase is in the format
{
"hash0": "very-long-string",
"hash1": "very-long-string",
"hash2": "very-long-string",
...
}
I wanted to use orderBy="$key", however I get the following error:
Actual code used:
let base = FirebaseApp.getDatabaseByUrl(url, env.token);
return base.getData("", {orderBy: `$key`, startAt: 0, limitToFirst: 5});
Omitting the second parameter on getData() entirely returns all the data, but since I have a lot of data it fails for the same reason as other users got in #23
A simple code returns
Error: We're sorry, a server error occurred. Please wait a bit and try again. (строка 236, файл Code, проект FirebaseApp)
Based on the G+ post
The TC are using the library
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.