1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- const mongoose = require('mongoose');
- const { Schema, model, SchemaTypes } = mongoose;
- const mongoosePaginate = require('mongoose-paginate-v2');
- mongoose.Types.ObjectId.isValid();
- const chatSchema = new Schema(
- {
- companionId: {
- type: String,
- },
- name: {
- type: String,
- default: null,
- },
- lastName: {
- type: String,
- default: null,
- },
- avatarUrl: {
- type: String,
- default: null,
- },
- color: {
- type: String,
- default: null,
- },
- online: {
- type: String,
- default: null,
- },
- number: {
- type: String,
- min: 8,
- max: 14,
- },
- owner: {
- type: SchemaTypes.ObjectId,
- ref: 'user',
- },
- },
- { timestamps: true }
- );
- chatSchema.plugin(mongoosePaginate);
- const Chat = model('chat', chatSchema);
- module.exports = Chat;
|