123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- const { boolean } = require('joi');
- 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,
- },
- originalName: {
- type: String,
- default: null,
- },
- originalLastName: {
- type: String,
- default: null,
- },
- avatarUrl: {
- type: String,
- default: null,
- },
- avatarsArr: {
- type: Array,
- default: [],
- },
- color: {
- type: String,
- default: null,
- },
- online: {
- type: String,
- default: null,
- },
- lastMessage: {
- type: String,
- default: null,
- },
- lastMessageCreatedAt: {
- type: String,
- default: null,
- },
- mute: {
- type: Boolean,
- default: false,
- },
- seen: {
- type: Number,
- default: 0,
- },
- seenCompanion: {
- type: Number,
- default: 0,
- },
- sort: {
- type: Boolean,
- default: false,
- },
- total: {
- type: Number,
- default: 0,
- },
- watched: {
- type: Boolean,
- default: false,
- },
- typing: {
- type: Boolean,
- default: false,
- },
- number: {
- type: String,
- min: 8,
- max: 14,
- },
- country: {
- type: String,
- default: false,
- },
- pinned: {
- type: Boolean,
- default: false,
- },
- socketId: {
- type: String,
- default: false,
- },
- owner: {
- type: SchemaTypes.ObjectId,
- ref: 'user',
- },
- },
- { timestamps: true }
- );
- chatSchema.plugin(mongoosePaginate);
- const Chat = model('chat', chatSchema);
- module.exports = Chat;
|