给字段添加了索引

This commit is contained in:
pqcqaq 2024-10-16 23:53:54 +08:00
parent 1f400f4579
commit ca74829c2d
4 changed files with 74 additions and 14 deletions

View File

@ -1,14 +1,12 @@
import {
String,
} from 'oak-domain/lib/types/DataType';
import { EntityDesc, EntityShape } from "oak-domain/lib/types";
import { String } from 'oak-domain/lib/types/DataType';
import { EntityDesc, EntityShape } from 'oak-domain/lib/types';
import { Schema as User } from 'oak-general-business/lib/entities/User';
import { Schema as ExtraFile } from 'oak-general-business/lib/entities/ExtraFile';
// Category.ts
export interface Schema extends EntityShape {
name: String<32>
description: String<256>
name: String<32>;
description: String<256>;
creator: User;
images: ExtraFile[];
}
@ -22,7 +20,21 @@ export const entityDesc: EntityDesc<Schema> = {
description: '描述',
creator: '创建者',
images: '图片',
}
}
}
}
},
},
},
indexes: [
{
name: 'name_unique',
attributes: [
{
name: 'name',
},
],
config: {
unique: true,
type: 'fulltext',
},
},
],
};

View File

@ -73,7 +73,7 @@ export const entityDesc: EntityDesc<
withdrawn: '已撤回',
},
},
}
},
},
style: {
icon: {},
@ -85,4 +85,19 @@ export const entityDesc: EntityDesc<
},
},
},
indexes: [
{
name: 'title_unique',
attributes: [
{
name: 'title',
},
],
config: {
unique: true,
// 索引类型,方便根据标题查找文章
type: 'fulltext',
},
},
],
};

View File

@ -40,7 +40,7 @@ export const entityDesc: EntityDesc<Schema, Action> = {
moveTo: '移动到',
moveToFirst: '移动到最前',
moveToLast: '移动到最后',
}
},
},
},
style: {
@ -50,6 +50,25 @@ export const entityDesc: EntityDesc<Schema, Action> = {
moveTo: 'arrow-right',
moveToFirst: 'arrow-right',
moveToLast: 'arrow-right',
}
}
},
},
indexes: [
{
name: 'essay_label_unique',
attributes: [
{
name: 'essay',
direction: 'ASC',
},
{
name: 'label',
direction: 'ASC',
},
],
config: {
unique: true,
type: 'btree',
},
},
],
};

View File

@ -39,4 +39,18 @@ export const entityDesc: EntityDesc<Schema, Action> = {
addToEssay: 'tag',
},
},
indexes: [
{
name: 'name_unique',
attributes: [
{
name: 'name',
},
],
config: {
unique: true,
type: 'fulltext',
},
},
],
};