Skip to content

Commit

Permalink
Remove the prepareFieldAdapter method (#2544)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Mar 19, 2020
1 parent ca28681 commit cec7ba5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .changeset/twelve-clouds-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@keystonejs/adapter-knex': major
'@keystonejs/adapter-mongoose': major
'@keystonejs/keystone': major
---

Removed the `prepareFieldAdapter()` method of `BaseListAdapter`, `MongooseAdapter` and `KnexListAdapter`. No action is required unless you were explicitly using this method in your code.
2 changes: 0 additions & 2 deletions packages/adapter-knex/lib/adapter-knex.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ class KnexListAdapter extends BaseListAdapter {
this.rels = undefined;
}

prepareFieldAdapter() {}

_postConnect({ rels }) {
this.rels = rels;
this.fieldAdapters.forEach(fieldAdapter => {
Expand Down
12 changes: 7 additions & 5 deletions packages/adapter-mongoose/lib/adapter-mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ class MongooseAdapter extends BaseKeystoneAdapter {
...mongooseConfig,
});
}

async postConnect({ rels }) {
// Setup all schemas
Object.values(this.listAdapters).forEach(listAdapter => {
listAdapter.fieldAdapters.forEach(fieldAdapter => {
fieldAdapter.addToMongooseSchema(listAdapter.schema, listAdapter.mongoose);
});
});

return await pSettle(
Object.values(this.listAdapters).map(listAdapter => listAdapter.postConnect({ rels }))
);
Expand Down Expand Up @@ -134,10 +140,6 @@ class MongooseListAdapter extends BaseListAdapter {
this.rels = undefined;
}

prepareFieldAdapter(fieldAdapter) {
fieldAdapter.addToMongooseSchema(this.schema, this.mongoose);
}

/**
* Note: It's not necessary to await the result of this function - it is only
* if you want access to the underlying model should you await it. Otherwise,
Expand Down
3 changes: 0 additions & 3 deletions packages/keystone/lib/adapters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class BaseListAdapter {

newFieldAdapter(fieldAdapterClass, name, path, field, getListByKey, config) {
const adapter = new fieldAdapterClass(name, path, field, this, getListByKey, config);
this.prepareFieldAdapter(adapter);
adapter.setupHooks({
addPreSaveHook: this.addPreSaveHook.bind(this),
addPostReadHook: this.addPostReadHook.bind(this),
Expand All @@ -86,8 +85,6 @@ class BaseListAdapter {
return adapter;
}

prepareFieldAdapter() {}

addPreSaveHook(hook) {
this.preSaveHooks.push(hook);
}
Expand Down

0 comments on commit cec7ba5

Please sign in to comment.