I am trying to validate and save a Passport profile with this structure:
http://passportjs.org/guide/profile/
This is the scheme I came up with:
// Define the schema. schema = new mongoose.Schema({ // The name of this user, suitable for display. displayName: String, // Each e-mail address ... emails: [{ // ... with the actual email address ... value: String, // ... and the type of email address (home, work, etc.). type: String }], // A unique identifier for the user, as generated by the service provider. id: String, // The name ... name: { // ... with the family name of this user, or "last name" in most Western languages ... familyName: String, // ... with the given name of this user, or "first name" in most Western languages ... givenName: String, // ... and with the middle name of this user. middleName: String }, // The provider which with the user authenticated. provider: String });
The e-mail has a property called 'type', which is reserved for a mongoose type. How do I solve this?
type is a special property in Mongoose schemas. When Mongoose finds a nested property named type in your schema, Mongoose assumes that it needs to define a SchemaType with the given type.
find() function returns an instance of Mongoose's Query class. The Query class represents a raw CRUD operation that you may send to MongoDB. It provides a chainable interface for building up more sophisticated queries. You don't instantiate a Query directly, Customer.
The __v field is called the version key. It describes the internal revision of a document. This __v field is used to track the revisions of a document. By default, its value is zero.
Mongoose is an Object Data Modeling (ODM) library for MongoDB and Node. js. It manages relationships between data, provides schema validation, and is used to translate between objects in code and the representation of those objects in MongoDB.
You need to define the field using an object:
type: {type: String}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With