const mongoose = require('mongoose');
const { Schema, model, SchemaTypes } = mongoose;
const mongoosePaginate = require('mongoose-paginate-v2');

mongoose.Types.ObjectId.isValid();

const contactSchema = new Schema(
	{
		companionId: {
			type: String,
			default: null,
		},
		name: {
			type: String,
			default: null,
		},
		lastName: {
			type: String,
			default: null,
		},
		number: {
			type: String,
			default: null,
		},
		country: {
			type: String,
			default: null,
		},
		avatarUrl: {
			type: String,
			default: null,
		},
		color: {
			type: String,
			default: null,
		},
		owner: {
			type: SchemaTypes.ObjectId,
			ref: 'user',
		},
	},

	{ timestamps: true }
);
contactSchema.plugin(mongoosePaginate);
const Contact = model('contact', contactSchema);

module.exports = Contact;
