Unique JS Mongoose Podcast Validation

I am creating an application that uses the UID of a mobile device as one of the means of authenticating sessions to the parent model. My intention to be a user can be authenticated for several parents, but has only one session record in the database for each parent.

ParentSchema {
  sessions: [{
   device_uid: { type: String, unique: true }
  }]
}

A session is its own schema object (written inline for simplicity).

My question is: if I put a unique check on device_uid, is the sub-document check context for the parent IT element or ALL session sub-headers for ALL parents?

+4
source share
1 answer

device_uid sub-doc sessions , sessions device_uid. , device_uid.

+2

Source: https://habr.com/ru/post/1547344/


All Articles