0

I'm writing a simple web app that requires a poll - using Backbone which interfaces with a RESTful Node API and a Mongo DB.

The premise is simple: there are 5 topics, the web user can select one and lodge a vote. This will insert a document into Mongo which can then be counted for total votes.

Should I use BB models for the actual lodging of the vote or is just directly firing an API call to Node sufficient? I know that when modifying BB models you would use .save() but in this situation I'm not creating another model for the front-end - I'm just inserting a document into the DB.

Any ideas?

HankHendrix
  • 295
  • 2
  • 9

1 Answers1

2

Yes, I would recommend you use models on the server side, primarily for validation. Although it's technically very easy to insert straight JSON from the client, you shouldn't ever blindly trust data that a user sent you because it may very well be malicious. This is especially true if you're going to resurface that data to other users, but still a good practice regardless.

Nathan Friedly
  • 7,837
  • 3
  • 42
  • 59