You're almost there, but have a few syntax errors in your code. This should be closer:
exports.newUserSignup = functions.auth.user().onCreate(user => {
console.log('user created', user.email, user.uid);
const doc = admin.firestore().collection('users').doc();
return doc.set({
createDate: admin.database.ServerValue.TIMESTAMP,
modifiedDate: admin.database.ServerValue.TIMESTAMP,
username: 'blah',
email: user.email,
stat: 1,
uid: user.uid,
rowpointer: doc.id,
});
});
I highly recommend keeping the reference docs handy when you're having trouble with this type of exercise, as I found the problem pretty quickly when looking at CollectionReference.doc()
and DocumentReference
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…