F
F
First name Last name2015-11-12 18:59:34
Node.js
First name Last name, 2015-11-12 18:59:34

Sails JS: what is the unique validator for?

I sent the form to sails, and the data is duplicated in MongoDB, even though I set the unique property. Either I did not understand what it was for, or I did not write something correctly.

userName: {
      type: 'string',
      unique: true,
      required: true
    }

Explain, please. Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timofey, 2015-11-12
@mr_T

Perhaps the point is that you have migrate: 'safe' in your waterline configs, in which case migrations are not performed and indexes, respectively, are not created. Try migrating: 'alter' (only if not in a production environment!) or setting the indexes manually.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question