Skip to content

feat: add schema indexes #1138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/src/attachment/schemas/attachment.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class AttachmentStub extends BaseSchema {
@Prop({
type: String,
required: true,
index: true,
})
name: string;

Expand Down
10 changes: 8 additions & 2 deletions api/src/chat/schemas/subscriber.schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
Expand Down Expand Up @@ -29,12 +29,14 @@ export class SubscriberStub extends BaseSchema {
@Prop({
type: String,
required: true,
index: true,
})
first_name: string;

@Prop({
type: String,
required: true,
index: true,
})
last_name: string;

Expand Down Expand Up @@ -66,6 +68,7 @@ export class SubscriberStub extends BaseSchema {

@Prop({
type: String,
index: true,
})
foreign_id: string;

Expand Down Expand Up @@ -154,7 +157,10 @@ export type SubscriberDocument = THydratedDocument<Subscriber>;

export const SubscriberModel: ModelDefinition = LifecycleHookManager.attach({
name: Subscriber.name,
schema: SchemaFactory.createForClass(SubscriberStub),
schema: SchemaFactory.createForClass(SubscriberStub).index({
first_name: 1,
last_name: 1,
}),
});

export default SubscriberModel.schema;
Expand Down
2 changes: 1 addition & 1 deletion api/src/cms/schemas/content.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class ContentStub extends BaseSchema {
/**
* The title of the content.
*/
@Prop({ type: String, required: true })
@Prop({ type: String, required: true, index: true })
title: string;

/**
Expand Down
7 changes: 5 additions & 2 deletions api/src/nlp/schemas/nlp-sample-entity.schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
Expand Down Expand Up @@ -107,7 +107,10 @@ export type NlpSampleEntityDocument = THydratedDocument<NlpSampleEntity>;
export const NlpSampleEntityModel: ModelDefinition =
LifecycleHookManager.attach({
name: NlpSampleEntity.name,
schema: SchemaFactory.createForClass(NlpSampleEntityStub),
schema: SchemaFactory.createForClass(NlpSampleEntityStub).index(
{ sample: 1, entity: 1, value: 1 },
{ unique: true },
),
});

export default NlpSampleEntityModel.schema;
Expand Down
4 changes: 2 additions & 2 deletions api/src/nlp/schemas/nlp-sample.schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
Expand All @@ -26,7 +26,7 @@ export class NlpSampleStub extends BaseSchema {
/**
* The content of the sample.
*/
@Prop({ type: String, required: true })
@Prop({ type: String, required: true, index: true })
text: string;

/**
Expand Down
5 changes: 4 additions & 1 deletion api/src/nlp/schemas/nlp-value.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ export type NlpValueDocument = THydratedDocument<NlpValue>;

export const NlpValueModel: ModelDefinition = LifecycleHookManager.attach({
name: NlpValue.name,
schema: SchemaFactory.createForClass(NlpValueStub),
schema: SchemaFactory.createForClass(NlpValueStub).index(
{ value: 1, entity: 1 },
{ unique: true },
),
});

export default NlpValueModel.schema;
Expand Down