/
schema.js
69 lines (67 loc) 路 1.28 KB
/
schema.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
'use strict';
const { FOLDER_MODEL_UID, FILE_MODEL_UID } = require('../../constants');
module.exports = {
collectionName: 'upload_folders',
info: {
singularName: 'folder',
pluralName: 'folders',
displayName: 'Folder',
},
options: {},
pluginOptions: {
'content-manager': {
visible: false,
},
'content-type-builder': {
visible: false,
},
},
attributes: {
name: {
type: 'string',
min: 1,
required: true,
},
pathId: {
type: 'integer',
unique: true,
required: true,
},
parent: {
type: 'relation',
relation: 'manyToOne',
target: FOLDER_MODEL_UID,
inversedBy: 'children',
},
children: {
type: 'relation',
relation: 'oneToMany',
target: FOLDER_MODEL_UID,
mappedBy: 'parent',
},
files: {
type: 'relation',
relation: 'oneToMany',
target: FILE_MODEL_UID,
mappedBy: 'folder',
},
path: {
type: 'string',
min: 1,
required: true,
},
},
// experimental feature:
indexes: [
{
name: 'upload_folders_path_id_index',
columns: ['path_id'],
type: 'unique',
},
{
name: 'upload_folders_path_index',
columns: ['path'],
type: 'unique',
},
],
};