File

src/samples/schemas/sample.schema.ts

Extends

OwnableClass

Index

Properties

Properties

_id
Type : string
Decorators :
@Prop({type: String})
Optional description
Type : string
Decorators :
@ApiProperty({type: String, required: false, description: 'A description of the sample.'})
@Prop({type: String, required: false})
Optional isPublished
Type : boolean
Decorators :
@ApiProperty({type: Boolean, default: false, required: false, description: 'Flag is true when data are made publicly available.'})
@Prop({type: Boolean, required: false, default: false})
Optional owner
Type : string
Decorators :
@ApiProperty({type: String, required: false, description: 'The owner of the sample.'})
@Prop({type: String, required: false})
Optional sampleCharacteristics
Type : Record<string | >
Decorators :
@ApiProperty({type: Object, default: undefined, required: false, description: 'JSON object containing the sample characteristics metadata.'})
@Prop({type: Object, required: false, default: undefined})
sampleId
Type : string
Decorators :
@ApiProperty({type: String, default: () => , required: true, description: 'Globally unique identifier of a sample. This could be provided as an input value or generated by the system.'})
@Prop({type: String, unique: true, required: true, default: () => })
accessGroups
Type : string[]
Default value : []
Decorators :
@ApiProperty({type: undefined, description: 'Optional additional groups which have read access to the data. Users which are members in one of the groups listed here are allowed to access this data. The special group 'public' makes data available to all users.'})
@Prop({type: undefined, index: true})
Inherited from OwnableClass
Defined in OwnableClass:26
Optional instrumentGroup
Type : string
Decorators :
@ApiProperty({type: String, required: false, description: 'Optional additional groups which have read and write access to the data. Users which are members in one of the groups listed here are allowed to access this data.'})
@Prop({type: String, required: false})
Inherited from OwnableClass
Defined in OwnableClass:38
ownerGroup
Type : string
Decorators :
@ApiProperty({type: String, description: 'Defines the group which owns the data, and therefore has unrestricted access to this data. Usually a pgroup like p12151'})
@Prop({type: String, index: true})
Inherited from OwnableClass
Defined in OwnableClass:15
createdAt
Type : Date
Decorators :
@ApiProperty({type: Date, description: 'Date and time when this record was created. This property is added and maintained by mongoose.'})
@Prop({type: Date})
Inherited from QueryableClass
Defined in QueryableClass:40

NOTE: createdAt and updatedAt properties are handled automatically by mongoose when timestamps flag is set to true on a schema(https://mongoosejs.com/docs/guide.html#timestamps). We still need to keep the fields available here because of the response model and swagger documentation. They are not required so we don't need to provide them manually on create/update.

createdBy
Type : string
Decorators :
@ApiProperty({type: String, description: 'Indicate the user who created this record. This property is added and maintained by the system.'})
@Prop({type: String, index: true, required: true})
Inherited from QueryableClass
Defined in QueryableClass:15
updatedAt
Type : Date
Decorators :
@ApiProperty({type: Date, description: 'Date and time when this record was updated last. This property is added and maintained by mongoose.'})
@Prop({type: Date})
Inherited from QueryableClass
Defined in QueryableClass:50
updatedBy
Type : string
Decorators :
@ApiProperty({type: String, description: 'Indicate the user who updated this record last. This property is added and maintained by the system.'})
@Prop({type: String, required: true})
Inherited from QueryableClass
Defined in QueryableClass:26
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { ApiProperty } from "@nestjs/swagger";
import { Document } from "mongoose";
import { Attachment } from "src/attachments/schemas/attachment.schema";
import { OwnableClass } from "src/common/schemas/ownable.schema";
import { DatasetClass } from "src/datasets/schemas/dataset.schema";
import { v4 as uuidv4 } from "uuid";

export type SampleDocument = SampleClass & Document;

@Schema({
  collection: "Sample",
  toJSON: {
    getters: true,
  },
  timestamps: true,
})
export class SampleClass extends OwnableClass {
  @Prop({ type: String })
  _id: string;

  @ApiProperty({
    type: String,
    default: () => uuidv4(),
    required: true,
    description:
      "Globally unique identifier of a sample. This could be provided as an input value or generated by the system.",
  })
  @Prop({ type: String, unique: true, required: true, default: () => uuidv4() })
  sampleId: string;

  @ApiProperty({
    type: String,
    required: false,
    description: "The owner of the sample.",
  })
  @Prop({ type: String, required: false })
  owner?: string;

  @ApiProperty({
    type: String,
    required: false,
    description: "A description of the sample.",
  })
  @Prop({ type: String, required: false })
  description?: string;

  @ApiProperty({
    type: Object,
    default: {},
    required: false,
    description: "JSON object containing the sample characteristics metadata.",
  })
  @Prop({ type: Object, required: false, default: {} })
  sampleCharacteristics?: Record<string, unknown>;

  @ApiProperty({
    type: Boolean,
    default: false,
    required: false,
    description: "Flag is true when data are made publicly available.",
  })
  @Prop({ type: Boolean, required: false, default: false })
  isPublished?: boolean;
}

export class SampleWithAttachmentsAndDatasets extends SampleClass {
  /*
  @ApiProperty({ type: "array", items: { $ref: getSchemaPath(Attachment) } })
  @Prop([AttachmentSchema])*/
  // this property should not be present in the database model
  @ApiProperty({
    type: Attachment,
    isArray: true,
    required: false,
    description: "Attachments that are related to this sample.",
  })
  attachments?: Attachment[];

  /*
  @ApiProperty({ type: "array", items: { $ref: getSchemaPath(Dataset) } })
  @Prop([DatasetSchema])*/
  // this property should not be present in the database model
  @ApiProperty({
    type: DatasetClass,
    isArray: true,
    required: false,
    description: "Datasets that are related to this sample.",
  })
  datasets?: DatasetClass[];
}

export const SampleSchema = SchemaFactory.createForClass(SampleClass);

SampleSchema.index({ "$**": "text" });

results matching ""

    No results matching ""