Skip to content

Commit

Permalink
Remove legacy list adapter methods (#5324)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Mar 31, 2021
1 parent bdf6235 commit e702fea
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 33 deletions.
7 changes: 7 additions & 0 deletions .changeset/funny-needles-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@keystone-next/adapter-prisma-legacy': major
'@keystone-next/fields-legacy': patch
'@keystone-next/keystone-legacy': patch
---

Removed legacy `.find()`, `.findAll()`, `.findOne()`, `.findById()`, `.itemsQueryMeta()`, `.getFieldAdapterByPath()`, and `.getPrimaryKeyAdapter()` methods from `PrismaListAdapter`.
30 changes: 0 additions & 30 deletions packages/adapter-prisma/src/adapter-prisma.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,41 +216,11 @@ class PrismaListAdapter {
return this.onPostRead(this._update(id, await this.onPreSave(data)));
}

async findAll() {
return Promise.all((await this._itemsQuery({})).map(item => this.onPostRead(item)));
}

async findById(id) {
return this.onPostRead((await this._itemsQuery({ where: { id }, first: 1 }))[0] || null);
}

async find(condition) {
return Promise.all(
(await this._itemsQuery({ where: condition })).map(item => this.onPostRead(item))
);
}

async findOne(condition) {
return this.onPostRead((await this._itemsQuery({ where: condition, first: 1 }))[0]);
}

async itemsQuery(args, { meta = false, from = {} } = {}) {
const results = await this._itemsQuery(args, { meta, from });
return meta ? results : Promise.all(results.map(item => this.onPostRead(item)));
}

itemsQueryMeta(args) {
return this.itemsQuery(args, { meta: true });
}

getFieldAdapterByPath(path) {
return this.fieldAdaptersByPath[path];
}

getPrimaryKeyAdapter() {
return this.fieldAdaptersByPath['id'];
}

_setupModel({ rels, prisma }) {
// https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema/models#queries-crud
// "By default the name of the property is the lowercase form of the model name,
Expand Down
2 changes: 1 addition & 1 deletion packages/fields/tests/test-fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const skipCommonFilterTest = true;

const getIDs = async keystone => {
const IDs = {};
await keystone.lists['Test'].adapter.findAll().then(data => {
await keystone.lists['Test'].adapter.itemsQuery({}).then(data => {
data.forEach(entry => {
IDs[entry.name] = entry.id.toString();
});
Expand Down
2 changes: 0 additions & 2 deletions packages/keystone/tests/List.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class MockListAdapter {
this.index += 1;
return this.items[this.index - 1];
};
findById = id => this.items[id];
delete = async id => {
this.items[id] = undefined;
};
Expand All @@ -144,7 +143,6 @@ class MockListAdapter {
: ids.filter(i => !id_not_in || !id_not_in.includes(i)).map(i => this.items[i]);
}
};
itemsQueryMeta = async args => this.itemsQuery(args, { meta: true });
update = (id, item) => {
this.items[id] = { ...this.items[id], ...item };
return this.items[id];
Expand Down

1 comment on commit e702fea

@vercel
Copy link

@vercel vercel bot commented on e702fea Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.