Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit c38509c

Browse files
committed
Updated docs examples
1 parent 3a48fd1 commit c38509c

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
## Installation
1212

1313
```bash
14-
npm install feathers-objection --save
14+
npm install --save feathers-objection
15+
npm install --save objection
16+
npm install --save knex
1517
```
1618

1719
## Documentation
@@ -28,6 +30,38 @@ It works almost the same as the [Knex
2830
service](https://github.com/feathersjs/feathers-knex) adapter, except it has all
2931
the benefits of the Objection ORM.
3032

33+
### Knex
34+
35+
config/defaults.json
36+
```js
37+
{
38+
"mysql": {
39+
"host": "mysql.example.com",
40+
"user": "root",
41+
"password": "secret",
42+
"database": "example"
43+
}
44+
}
45+
```
46+
47+
knex.js
48+
```js
49+
const { Model } = require('objection');
50+
51+
module.exports = function (app) {
52+
const connectionInfo = app.get('mysql');
53+
const knex = require('knex')({
54+
client: 'mysql',
55+
useNullAsDefault: false,
56+
connection: connectionInfo,
57+
});
58+
59+
Model.knex(knex);
60+
61+
app.set('knex', knex);
62+
};
63+
```
64+
3165
### Models
3266

3367
Objection requires you to define Models for your tables:

0 commit comments

Comments
 (0)