Skip to content

Commit ca55306

Browse files
committed
udpate readme
1 parent cc92382 commit ca55306

File tree

1 file changed

+37
-39
lines changed

1 file changed

+37
-39
lines changed

readme.md

+37-39
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,40 @@ db.public.many(`select * from test`) // => {test: 'value'}
9090
```
9191

9292

93+
## Custom functions
94+
95+
You can declare custom functions like this:
96+
97+
```typescript
98+
db.public.registerFunction({
99+
name: 'say_hello',
100+
args: [DataType.text],
101+
returns: DataType.text,
102+
implementation: x => 'hello ' + x,
103+
})
104+
```
105+
106+
And then use them like in SQL `select say_hello('world')`.
107+
108+
Custom functions support overloading and variadic arguments.
109+
110+
⚠ However, the value you return is not type checked. It MUST correspond to the datatype you provided as 'returns' (wont fail if not, but could lead to weird bugs).
111+
112+
113+
## Extensions
114+
115+
No native extension is implemented (pull requests are welcome), but you can define kind-of extensions like this:
116+
117+
```typescript
118+
119+
db.registerExtension('my-ext', schema => {
120+
// install your ext in 'schema'
121+
// ex: schema.registerFunction(...)
122+
});
123+
```
124+
125+
Statements like `create extension "my-ext"` will then be supported.
126+
93127
# 📃 Libraries adapters
94128

95129

@@ -190,45 +224,9 @@ __NB: Restore points only work if the schema has not been changed after the rest
190224

191225
note: You must install `typeorm` module first.
192226

193-
# Other features
194-
195-
## Custom functions
196-
197-
You can declare custom functions like this:
198-
199-
```typescript
200-
db.public.registerFunction({
201-
name: 'say_hello',
202-
args: [DataType.text],
203-
returns: DataType.text,
204-
implementation: x => 'hello ' + x,
205-
})
206-
```
207-
208-
And then use them like in SQL `select say_hello('world')`.
209-
210-
Custom functions support overloading and variadic arguments.
211-
212-
⚠ However, the value you return is not type checked. It MUST correspond to the datatype you provided as 'returns' (wont fail if not, but could lead to weird bugs).
213-
214-
215-
## Extensions
216-
217-
No native extension is implemented (pull requests are welcome), but you can define kind-of extensions like this:
218-
219-
```typescript
220-
221-
db.registerExtension('my-ext', schema => {
222-
// install your ext in 'schema'
223-
// ex: schema.registerFunction(...)
224-
});
225-
```
226-
227-
Statements like `create extension "my-ext"` will then be supported.
228-
229-
## Extensions
227+
# Inspection
230228

231-
## 💥 Inspection subscriptions
229+
## 💥 Subscribe to events
232230
You can subscribe to some events, like:
233231

234232
```typescript
@@ -244,7 +242,7 @@ db.on('schema-change', () => {});
244242
db.on('create-extension', ext => {});
245243
```
246244

247-
## Experimental inspection subscriptions
245+
## Experimental events
248246

249247
`pg-mem` implements a basic support for indices.
250248

0 commit comments

Comments
 (0)