Cloud Functions for Firebase database trigger?

Viewed 541

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)
2 Answers
Related