Reputation: 2084
I'm trying to add data to Firestore but I need to save it as a number. The problem is, Firestore automatically stores everything as a string by default. How do you change this?
//Add to Firestore
this.afs.collection(placeToSearchSubmit).add({
title: thingName,
type: thingType,
value: thingValue <-- I need this to be a number
});
Upvotes: 1
Views: 1905
Reputation: 2084
Figured it out. Adding +
at the front of a variable automatically casts it to an integer, but it's not the only way.
Example
let thing2 = +thing.value;
Upvotes: 3