Increase firebase cloud firestore string upload size - firebase

Hello I am using firebase and I am running into an error when I am trying to store a (large) data object into the database. Here is the exact error I am getting:
ERROR Error: Uncaught (in promise): FirebaseError: [code=invalid-argument]: The value of property "values" is longer than 1048487 bytes.
This is because firebase doesnt allow storage of strings larger than 1048487 bytes. (documentation).
Has anyone experienced this before and found a way to increase the store limit? From what I have read it doesn't seem like purchasing a plan will fix this.
Here is the code I am using to store the data just incase its needed:
storeSearchItem(searchItem, userID, data) {
this.db.collection('users').doc(userID).collection('searches').add({
searchTerm: searchItem.searchTerm,
searchDate: new Date().toString(),
values: data, //this values property is huge, a couple megabytes
});
}

The documentation is telling you there is a hard limit. It can't be changed. You will have to find a different way to store your data.

Related

How do I make a query equalto with a long value?

I tried to make a query from real time database using equalTo().
database.getReference(verifiedProductsDb.dbPartVerifiedProducts).order By Child(verifiedProductsDb.barcode).equalTo(b.toLong()).get().addOnCompleteListener {
but android studio gives out:
None of the following functions can be called with the argument supplied.
equalTo(Boolean) defined in com.google.firebase.database.Query
equalTo(Double) defined in com.google.firebase.database.Query
equal To(String?) defined in com.google.firebase.database.Query
Despite the fact that using setValue, long values are written to the same database quite successfully and without problems.
The Realtime Database API on Android only has support for Double number types. The underlying wire protocol and database will interpret the long numbers correctly though, so you should be able to just do:
database.getReference("VerifiedProducts")
.orderByChild("barcode")
.equalTo(b.toLong().toDouble()) // 👈
.get().addOnCompleteListener {
...

Firestore REST API batchGet returns status 400

I am trying to get data from Firestore in a batch using the batchGet method. But i get an error as below :
Error: JSON error response from server: [{"error":{"code":400,"message":"Document name "["projects/MYPROJECT/databases/(default)/documents/MYCOLLECTION/DOCUMENTID"]" lacks "projects" at index 0.","status":"INVALID_ARGUMENT"}}].status: 400
I have searched for any questions regarding this, I found this. They are trying t add documents and not using batchGet, however I have followed the solution. Still no luck.
Note: I am integrating Firebase to AppGyver.
I am new to Firebase and still learning. I need all the help I can get. Thank you in advance.
I have found what I did wrong.
In AppGyver you can only set your parameters as text or number only. While the documents parameter needs to be in array. Hence, I convert the array to string using ENCODE_JSON. But that was wrong.
The correct way is just send the documents in array without converting it. Use the formula :
Just hit "Save" even there is an error telling you that it is not a text.

Firebase is giving "maxretry" error

We're using Firebase as a backend for our mobile app. Some of our users have sporadically received an error "maxretry" with a transaction writing to a path with single numeric value. We don't have multiple users or connections, nor multiple writes to the same path, as far as I know. What might be causing this?
I have a suspicion that this is caused by using floating point values with many decimal places. This error happened to me locally once and I was able to resolve it by limiting the precision to two decimal places. Can this be it?
-Albert
Edit:
Here's the code that is causing this:
return fireRef.child(fbPath).transaction(function(originalVal) {
return func(originalVal, by_value);
}, _.noop, false)
where in this case the func looks like this:
function(originalVal, val) {
return val + (originalVal || 0);
}
The problem persisted even after limiting precision to 2 decimals (getting maxretry error every once in a while).
It looks like when updating a value using Firebase transactions floating point type should not be used at all.
I moved to using integers and haven't had the problem anymore.

MeteorJS: Store/Call MongoDB Document Size (bsonsize)

In my MeteorJS app, documents grow very rapidly. When documents reach the 16MB, standard document size limit in MongoDB, my application starts erroring, notifying me that the document size is too large to perform any more updates to the document:
exception: BSONObj size: 16895320 (0xEEEEEEEE) is invalid. Size must be between 0 and 16793600(16MB)
To prevent my application from reaching this state of error, I want to be able to lookup the size (bsonsize) of a the document ahead of time. If the bsonsize is above, say 15.8MB, create a new document and start logging data there. This way, no errors will be encountered.
Using the Mongo Shell, bsonsize can be determined via: Object.bsonsize(db.collection.findOne({_id:'document id here'})). But Object.bsonsize() does not appear to be supported by Meteor within javascript:
TypeError: Object function Object() { [native code] } has no method 'bsonsize'
How can this be done in javascript/MeteorJS? Thanks!

When I connect to firebase, I only see the structures and no devices (Nest API)

I am trying to read basic information about thermostats using the methods in the thermostat control example (https://developer.nest.com/documentation/control), but when I connect to firebase I only see the structure object (which only contains name, away, smoke_co_alarms, structure_id and thermostats) in the snapshot– There is no devices object. I am connecting to firebase using
var nestToken = $.cookie('nest_token');
var dataRef = new Firebase('wss://developer-api.nest.com/');
dataRef.auth(nestToken);
I tried to connect directly to devices using wss://developer-api.nest.com/devices, but that only returns an undefined data-structure.
I've also tried connecting to firebase using https://developer-api.nest.com/ and https://developer-api.nest.com/, but they raised an authorization error and caused my javascript to go into an infinite loop sending requests.
I'm reading data using:
dataRef.on('value', function (snapshot) {
var data = snapshot.val();
structure = firstChild(data.structures);
console.log(data);
console.log(data.structures);
console.log(data.devices);
console.log(data.devices.thermostats);
console.log(structure.thermostats);
};
Lastly, I tried it on an account with real devices and one with virtual devices, so I know that couldn't be causing it (even though I didn't expect it to).
Any ideas what I am doing wrong? The issue couldn't be in my App.js file, could it? Is there some configuration I need to do on the user's end in addition to the authentication? I get the feeling it's probably something really simple that's staring me in the face.
So I figured it out: It's a permissions issue. When my client-profile was setup, it only requested permission to read the away/home status. So when I query Firebase it only returns the a snapshot with structure because that is where the away/home status can be read. So, in summary, if you're not seeing the devices structure, even though devices are associated with the user, check your client permissions.
Using (some of) your code, I have no trouble seeing the devices object:
var dataRef = new Firebase('wss://developer-api.nest.com');
dataRef.auth(nestTokenLive);
dataRef.on('value', function (snapshot) {
var data = snapshot.val();
console.log(data);
console.log(data.devices);
});
Results in:
> Object {devices: Object, structures: Object}
> Object {thermostats: Object}

Resources