2

I need to find a way to log user's activities in my Compound.JS + MongoDB app.

It would be great to create a table and insert information like who (what login) updated/created/deleted which record in what table, what fields were changed from what to what?

I thought there might be a npm-package for this, but so far in google I find only about logging (writing to log-file) which is not what I want.

xaxa
  • 1,057
  • 1
  • 24
  • 53

1 Answers1

1

If you want to save it to a MongoDB collection, why not just create a model for it and save away?

LoggingModel.create({ user : req.session.user.id, action : "Created a new user." });
LoggingModel.create({ user : req.session.user.id, action: "Deleted user with id " + aId + "."});
Jite
  • 5,761
  • 2
  • 23
  • 37
  • Where should I put this code? I cannot use `req` in DB filters (like `beforeUpdate()`), while placing this in every controller after each update/create is no good. – xaxa Sep 14 '13 at 12:31
  • If you attach the logged in user id to the compound object (like in the login controller) you can reach it from the models. – Jite Sep 15 '13 at 12:27