TypeError: database.collection(...).set is not a function at onFinish code example

Example: TypeError: database.collection(...).set is not a function at onFinish

db.collection("users") returns an object of CollectionReference. CollectionReference has no function 'set', Hence the error. Perhaps you are looking for the function 'add' which adds documents.

Replace

                db.collection("users").set({
                    points: 0,
                    CurrentLevel: 0
                })
with

                db.collection("users").add({
                    points: 0,
                    CurrentLevel: 0
                })
And I think that should solve your problem

Tags:

Misc Example