[voting app] Best schema to store the data?

Still thinking about the best way to store the data.
We have the questions and responses but not sure about storing the votes.
I was thinking of a separate collection of documents?
Any ideas?
Also, how do you store the users detail to stop them voting again?

The best way to store almost any kind of data is using a database, i would recommend mlab + mongoose approach. If this was your question.

We are storing it in Mongo hosted on mlab which works well but my question is more about the best Schema to use.
Sorry for not making that clear :confused:

This is what we have so far and you should be able to add a new poll.
https://voting-app-bizzel.c9users.io/

1 Like

You would want to use a database like mongodb to store the data. As for the user info, that would deal with authentication to ensure a user is logged in. From there you could limit what they do.

The rules are that none subscribed users can vote. But in someone else’s final project that I saw, they stopped the anonymous user voting for the same question twice.

I think that anonymous votes aren`t allowed, however if you plan to do that you need to save their ip adress to the database.

About the schema i think an array with persons that voted for a topic would be the way to go.

1 Like

I was thinking of creating a separate collection on MongoDb for the votes, like you say as an array of persons and votes - linked with the Poll ID.

Anybody can see and vote on any poll, as per the user story.

1 Like

In line the only collection I had was for ‘polls’, and the polls had an array of users in them that had voted.

I don’t let anonymous eggs vote :slight_smile:

1 Like

I think we will store the votes per response and then try cookies to store votes already cast.
That’s the plan.