Note that there are some explanatory texts on larger screens.

plurals
  1. POnode stack for user submitted pages
    text
    copied!<p>I'm aiming to create a "Yahoo! Answers" or "wiki answers" type website, where people can sign up and post questions and also answer questions. (This website will be geared towards asking and answering math/chem/physics homework questions. It will be configured so that users can type in LaTeX markup in both the questions and answers sections).</p> <p>In effect, it will be the stackoverflow of answering homework questions, where people can ask questions, post solutions, and upvote questions and solutions like how you can on stackoverflow. </p> <p>I had a prototype up at <a href="http://www.university-answers.com/" rel="nofollow">http://www.university-answers.com/</a> , but I have yet to implement user sign-ups, or user submitted questions or answers. </p> <p>I've looked into using <a href="https://github.com/jaredhanson/passport" rel="nofollow">Passport</a> for user authentication, and tried to follow some tutorials on getting user authentication and storing it on mongodb (like <a href="http://danialk.github.io/blog/2013/02/23/authentication-using-passportjs/" rel="nofollow">this tutorial</a>). I can get usernames and passwords to authenticate and store in a database so that they can log in later. However, I don't know how to keep track of each user's questions submitted and answers submitted. For example, on stackoverflow I can go to my account's page and see what questions I have submitted and what answers I have submitted. Do I need to store a user's comments and questions along with their username and password in the database? </p> <p><strong>Edit:</strong> As a follow-up question after researching this. I read up on <a href="http://docs.mongodb.org/manual/core/data-model-design/" rel="nofollow">Data Model Design</a> and I have reasoned that I could make the following structures for a database:</p> <pre><code>user{ _id:&lt;object1&gt;, username: input-data, password: however-this-is-done, questions[]: &lt;object2&gt;[], //an array of &lt;object2&gt; type objects? if this is possible solutions[]: &lt;object3&gt;[], //an array of &lt;object3&gt; objects, which are submitted //solutions. if it is possible to create arrays of "references" } question{ _id:&lt;object2&gt;, user_id:&lt;object1&gt;, body:input-data, solutions[]:&lt;object3&gt;[], //array of references? } solutions{ _id:&lt;object3&gt;, user_id:&lt;object1&gt;, question_id:&lt;object2&gt;, body:user-input } </code></pre> <p>After a user authenticates, it should be made able to post under its user_id. If user posts a question, it should run a function that creates a <code>question</code> object, that has its <code>user_id</code> attribute set to the client's user info. The <code>question</code> object should have an array of <code>solution</code> objects, that each have data that references back to current <code>user_id</code> and the solution's <code>question</code> object. How do I write functions in node.js that do this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload