NocoBase provides DataSourceManager for managing multiple data sources. Each DataSource has its own Database, ResourceManager, and ACL instances, making it convenient for developers to flexibly manage and extend multiple data sources.
Each DataSource instance contains the following:
dataSource.collectionManager: Used to manage collections and fields.dataSource.resourceManager: Handles resource-related operations (such as CRUD, etc.).dataSource.acl: Access control (ACL) for resource operations.For convenient access, aliases are provided for main data source members:
app.db is equivalent to dataSourceManager.get('main').collectionManager.dbapp.acl is equivalent to dataSourceManager.get('main').aclapp.resourceManager is equivalent to dataSourceManager.get('main').resourceManagerThis method returns the specified DataSource instance.
Register middleware for all data sources. This will affect operations on all data sources.
Executes before data source loading. Commonly used for static class registration, such as model classes and field type registration:
Executes after data source loading. Commonly used for registering operations, setting access control, etc.
For complete data source extension, please refer to the data source extension chapter.