ad4929e48b
* Turkish language created for Docs. Belgeler için türkçe dil desteği oluşturuldu. * Turkish docs fix
1.3 KiB
1.3 KiB
Collection templates
📢 Collection templates are scheduled to be available in Q4 2022.In real business scenarios, different collections may have their own initialization rules and business logic, and NocoBase addresses such issues by providing collection templates.
General collections
db.collection({
name: 'posts',
fields: [
{
type: 'string',
name: 'title',
}
],
});
Tree structure collections
db.collection({
name: 'categories',
tree: 'adjacency-list',
fields: [
{
type: 'string',
name: 'name',
},
{
type: 'string',
name: 'description',
},
{
type: 'belongsTo',
name: 'parent',
target: 'categories',
foreignKey: 'parentId',
},
{
type: 'hasMany',
name: 'children',
target: 'categories',
foreignKey: 'parentId',
},
],
});
Parent-child inheritance collections
db.collection({
name: 'a',
fields: [
],
});
db.collection({
name: 'b',
inherits: 'a',
fields: [
],
});
More templates
As in the case of calendar collections, each initialized collection needs to be initialized with special cron and exclude fields, and the definition of such fields is done by the template
db.collection({
name: 'events',
template: 'calendar',
});