Skip to content
Advertisement

Tag: mongoose-schema

UnhandledPromiseRejectionWarning: ValidationError

I’m running into a trouble since a few days. I’m learning the MEAN stack, but during creation of a user on mongo using mongoose schema, I have this problem : (node:93337) UnhandledPromiseRejectionWarning: ValidationError: User validation failed: username: Path username is required., password: Path password is required., email: Path email is required. Here’s my code : The server part : …

Returning specific fields with mongoose

I’m trying to accomplish something really easy but still manage to fail. What I am trying to do is when I get a get request on my server I want to return all documents BUT just the specific fields populated. My schema goes as follows What I want is to return only client.phone and client.email plus orderdetails.status but still retain

Advertisement