I want to store all users ID of users clicking on a button of my Messenger Bot. I'm not really familiar with Javascript and MongoDB. I tried this but it seems it's not working:
-Index.js:
// DB
var mongoose = require("mongoose");
var db = mongoose.connect(process.env.MONGODB_URI);
var User = require("./models/user");
-Model models/user.js
var mongoose = require("mongoose");
var Schema = mongoose.Schema;
var UserSchema = new Schema({
_id: {type: String}
});
module.exports = mongoose.model("User", UserSchema);
-Index.Js to save the User ids using a payload:
if (text === '{"payload":"SUB_YES_PAYLOAD"}') {
User.insert({ _id: event.sender.id })
sendTextMessage(sender, "Merci pour votre inscription ! Voici les derniers articles publiés :", token)
sendGenericMessage(sender)
continue
}
Thanks for your help!