0

I would like to know how does i have to set up my collections schemas?

I mean first i need ,for example, a user object (username,email,password), then i need a field to make users confirm registration so need i to insert all fields when inserting users (username,email,password,confirm=0)

or

better to create confirm field only when user goes to confirm his registration account?

itsme
  • 48,972
  • 96
  • 224
  • 345

1 Answers1

1

The missing confirm field tells you that it's 0, so both seem to be fine, it's just a matter of taste.

Karoly Horvath
  • 94,607
  • 11
  • 117
  • 176
  • so if field does not exist and i anyway try to select that it will return error as for mysql fields? anyway i need to try that :P thx! – itsme Sep 12 '11 at 23:23
  • actually you rarely retrieve a single field with mongo.. you retrieve the whole document, and then you'll have a missing confirm field. `isset` vs `== 0`. – Karoly Horvath Sep 12 '11 at 23:28
  • uhmmm :) ... not totally agree, since there is the option to specify which field/fields to retrieve i think is important (as for mySQL) specify only fields that i need to return back don't you think? I'm newbie on mongo, this is just a new question :) – itsme Sep 13 '11 at 11:24
  • 1
    yes, I'm just saying it rarely used. actually in this case you don't need to retrieve any fields (just the `_id`) if you search for a document with `confirm: true`. – Karoly Horvath Sep 13 '11 at 11:28