2022-11-07 09:28:56 +08:00
# How to configure collections?
2022-11-02 11:33:07 +08:00
2022-11-07 09:28:56 +08:00
NocoBase has three ways to configure collections.
2022-11-02 11:33:07 +08:00
< img src = "./cm.svg" style = "max-width: 800px;" / >
2022-11-07 09:28:56 +08:00
## Configuring collections through the interface
2022-11-02 11:33:07 +08:00
2022-11-07 09:28:56 +08:00
Business data is generally recommended to be configured using the interface, and the NocoBase platform provides two interfaces to configure collections.
2022-11-02 11:33:07 +08:00
2022-11-07 09:28:56 +08:00
### Regular table interface
2022-11-02 11:33:07 +08:00
< img src = "./table.jpg" style = "max-width: 800px;" / >
2022-11-07 09:28:56 +08:00
### Graphical configuration interface
2022-11-02 11:33:07 +08:00
< img src = "./graph.jpg" style = "max-width: 800px;" / >
2022-11-07 09:28:56 +08:00
## Defined in the plugin code
2022-11-02 11:33:07 +08:00
2022-11-07 09:28:56 +08:00
Generally used to configure plugin functions or system configuration tables where users can read and write data, but cannot modify the data structure.
2022-11-02 11:33:07 +08:00
```ts
export class MyPlugin extends Plugin {
load() {
this.db.collection();
this.db.import();
}
}
```
2022-11-07 09:28:56 +08:00
Related API Reference
2022-11-02 11:33:07 +08:00
- [db.collection() ](/api/database#collection )
- [db.import() ](/api/database#import )
2022-11-07 09:28:56 +08:00
The collection configured in the plugin is automatically synchronized with the database when the plugin is activated, giving birth to the corresponding data tables and fields.
2022-11-02 11:33:07 +08:00
2022-11-07 09:28:56 +08:00
## Managing data tables via REST API
2022-11-02 11:33:07 +08:00
2022-11-07 09:28:56 +08:00
Third parties can also manage data tables via the HTTP interface (permissions required)
2022-11-02 11:33:07 +08:00
### Collections
```bash
2022-11-07 09:28:56 +08:00
GET /api/collections
POST /api/collections
GET /api/collections/< collectionName >
PUT /api/collections/< collectionName >
DELETE /api/collections/< collectionName >
2022-11-02 11:33:07 +08:00
```
### Collection fields
```bash
2022-11-07 09:28:56 +08:00
GET /api/collections/< collectionName > /fields
POST /api/collections/< collectionName > /fields
GET /api/collections/< collectionName > /fields/< fieldName >
PUT /api/collections/< collectionName > /fields/< fieldName >
DELETE /api/collections/< collectionName > /fields/< fieldName >
2022-11-02 11:33:07 +08:00
```