You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update plugin configuration and usage documentation
Clarified that plugins can be specified as instances or package names in the configuration. Expanded the plugins guide to explain both loading methods and added instructions for creating and publishing plugin packages.
Copy file name to clipboardExpand all lines: docs/guide/plugins.md
+45Lines changed: 45 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,6 +73,10 @@ export class SoftDeletePlugin implements ObjectQLPlugin {
73
73
74
74
## Usage
75
75
76
+
Plugins can be loaded in two ways: by instance or by package name.
77
+
78
+
### 1. By Instance (Local Development)
79
+
76
80
```typescript
77
81
const db =newObjectQL({
78
82
connection: 'sqlite://data.db',
@@ -81,3 +85,44 @@ const db = new ObjectQL({
81
85
]
82
86
});
83
87
```
88
+
89
+
### 2. By Package Name (Distribution)
90
+
91
+
If you have installed a plugin via npm (e.g. `npm install @objectql/plugin-audit`), you can simply pass its name. ObjectQL will automatically resolve and instantiate it.
92
+
93
+
```typescript
94
+
const db =newObjectQL({
95
+
connection: 'sqlite://data.db',
96
+
plugins: [
97
+
'@objectql/plugin-audit'
98
+
]
99
+
});
100
+
```
101
+
102
+
## Creating a Plugin Package
103
+
104
+
To publish a plugin as an npm package:
105
+
106
+
1. Create a project exporting your plugin class/instance as the `default` export (or named export).
0 commit comments