import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types, HydratedDocument } from 'mongoose';
import moment from 'moment';
import { Users } from './user.schema';

@Schema()
export class Workspace extends Document {

  @Prop({ type: String, default: null })
  name: string

  @Prop({ type: Types.ObjectId, ref: Users.name, default: null })
  created_by: Types.ObjectId = null

  @Prop({ type: String, default: null })
  index_name: string

  @Prop({ type: String, default: null })
  image: string

  @Prop({ type: String, default: null })
  description: string
  
  @Prop({ type: String, default: "UNBLOCK", enum:["UNBLOCK","BLOCK"] })
  status: string

  @Prop({ type: Boolean, default: false })
  is_admin_workspace: boolean

  @Prop({ type: Boolean, default: false })
  is_deleted: boolean

  @Prop({ default: moment().utc().valueOf() })
  created_at: number = moment().utc().valueOf();

  @Prop({ default: moment().utc().valueOf() })
  updated_at: number = moment().utc().valueOf();
}

export const workspaceSchema = SchemaFactory.createForClass(Workspace);