Skip to content

Commit

Permalink
fix: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-gilliotte committed Jul 27, 2023
1 parent e264a97 commit 91a19e3
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 25 deletions.
50 changes: 37 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/operational-database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
## Installation

```bash
yarn add @forestadmin/plugin-operational-database
yarn add @forestadmin-experimental/plugin-operational-database
```

## Limits
Expand Down
9 changes: 5 additions & 4 deletions packages/operational-database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
"publishConfig": {
"access": "public"
},
"devDependencies": {},
"scripts": {
"build": "tsc"
},
"dependencies": {
"@forestadmin/datasource-customizer": "^1.6.1",
"@forestadmin/datasource-sequelize": "^1.3.1",
"sequelize": "^6.32.0"
"sequelize": "^6.32.0",
"@forestadmin/datasource-sequelize": "^1.4.0"
},
"devDependencies": {
"@forestadmin/datasource-customizer": "^1.14.0"
}
}
18 changes: 11 additions & 7 deletions packages/operational-database/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createSequelizeDataSource } from "@forestadmin/datasource-sequelize";
import {
import type {
CollectionCustomizer,
DataSourceCustomizer,
} from "@forestadmin/datasource-customizer";
Expand All @@ -23,8 +23,12 @@ async function createOperationalTable(
await sequelize.sync();
}

function linkDatabases(collection: CollectionCustomizer, columns: Columns) {
// link main db collection to operational db collection
function linkDatabases(
dataSource: DataSourceCustomizer,
collection: CollectionCustomizer,
columns: Columns
) {
// link main db collection to operational db collection
collection.addOneToOneRelation(
"operational",
`operational_${collection.name}`,
Expand All @@ -42,9 +46,7 @@ function linkDatabases(collection: CollectionCustomizer, columns: Columns) {
collection.removeField("operational");

// remove operational db collection
// This actually does not work... we have a branch implementing this feature that
// has been waiting for months to be finished as it was deprioritized.
// dataSource.removeCollection(`operational_${collection.name}`);
dataSource.removeCollection(`operational_${collection.name}`);
}

export default async function addOperationalColumns(
Expand All @@ -60,5 +62,7 @@ export default async function addOperationalColumns(
dataSource.addDataSource(createSequelizeDataSource(sequelize));

// Link main db collection to operational db collection
linkDatabases(collection, options.columns);
linkDatabases(dataSource, collection, options.columns);
}

export { DataType, DataTypes };

0 comments on commit 91a19e3

Please sign in to comment.