Any idea why I can't use childByAutoId?
exports.addPersonalRecordHistory = functions.database.ref('/personalRecords/{userId}/current/{exerciseId}')
.onWrite(event => {
var path = 'personalRecords/' + event.params.userId + '/history/' + event.params.exerciseId;
var reference = admin.database().ref(path).childByAutoId();
reference.set({
username: "asd",
email: "asd"
});
});
Error
TypeError: admin.database(...).ref(...).childByAutoId is not a function
at exports.addPersonalRecordHistory.functions.database.ref.onWrite.event (/user_code/index.js:18:111)
childByAutoId() is for the iOS SDK. For admin.Database(), use push().
var reference = admin.database().ref(path).push();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With