This function is utilized to transmit data to Firestore
exports.professional = functions.https.onRequest((request, response) => {
const db = admin.firestore();
const userId: string = request.body['userId'];
const qualificationId: number = request.body['qualificationId'];
const occupationId: number = request.body['occupationId'];
const employmentType: EMPLOYMENT_TYPE = request.body['employmentType'];
const collegeOrInstitution: string = request.body['collegeOrInstitution'];
return db.collection('profiles').doc(userId)
.set(
{
professional: {
qualifaicationId: qualificationId,
occupationId: occupationId,
employmentType: employmentType,
collegeOrInstitution: collegeOrInstitution
}
},
{
merge: true
}).then(writeResult => {
return response.json(
{
status: 1,
message: 'Professional details saved successfully',
result: userId
}
)
});
});
Although I have designated certain variables as numbers, they are being stored as strings in the Firestore document. Please refer to the screenshot below:
https://i.sstatic.net/ClyLy.png
In the code, despite declaring occupationId
as a number variable, it appears as a string after being saved. Could someone explain why this data type change is occurring?