question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Postgresql error with Knex Adapter in KeystoneJS 5: 'Error: Cannot read property 'find' of undefined'

See original GitHub issue

I am new to Postgresql (more familiar with Mongo) but our DevOps want me to transition a KeystoneJS 5 project from Mongo to Postgresql. I followed the KeystoneJS instructions and all went fine until I tried adding the ‘atCreated’ plugin, specifically the ‘createdAtField’ plugin, to get a created date in my list. I started getting DB errors, and, thinking that I needed to rebuild the database, I ran the KeystoneJS init script to drop the database and rebuild it. Since then, I’ve gotten the following error:



      $ tsc && cross-env NODE_ENV=development DISABLE_LOGGING=true keystone --entry=tsout/index.js dev --port=4545
        ℹ Command: keystone dev --entry=tsout/index.js --port=4545
        ✔ Validated project entry file ./tsout/index.js
        ✔ Keystone server listening on port 4545
        ✔ Initialised Keystone instance
        ⠋ Connecting to databaseType "OEmbed" is missing a "__resolveType" resolver. Pass false into "resolverValidationOptions.requireResolversForResolveType" to disable this warning.
        setting up cron job
        ⠙ Connecting to database  knex:query select 1+1 as result undefined +0ms
        ⠹ Connecting to database  knex:query SHOW server_version; undefined +65ms
        ✖ Connecting to database
        Error: Cannot read property 'find' of undefined
            at /Users/ranthony/Documents/projects/yaa-keystone/node_modules/@keystonejs/utils/dist/utils.cjs.dev.js:57:21
            at async executeDefaultServer (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/@keystonejs/keystone/bin/utils.js:114:3) {
          errors: {
            KnexAdapter: TypeError: Cannot read property 'find' of undefined
                at /Users/ranthony/Documents/projects/yaa-keystone/node_modules/@keystonejs/adapter-knex/lib/adapter-knex.js:258:31
                at Array.forEach (<anonymous>)
                at KnexListAdapter._postConnect (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/@keystonejs/adapter-knex/lib/adapter-knex.js:257:24)
                at /Users/ranthony/Documents/projects/yaa-keystone/node_modules/@keystonejs/adapter-knex/lib/adapter-knex.js:73:19
                at Array.forEach (<anonymous>)
                at KnexAdapter.postConnect (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/@keystonejs/adapter-knex/lib/adapter-knex.js:72:38)
                at KnexAdapter.connect (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/@keystonejs/adapter-knex/node_modules/@keystonejs/keystone/lib/adapters/index.js:29:38)
                at async pReflect (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/p-reflect/index.js:5:17)
                at async Promise.all (index 0)
                at async executeDefaultServer (/Users/ranthony/Documents/projects/yaa-keystone/node_modules/@keystonejs/keystone/bin/utils.js:114:3)
          }
        }

The DB is obviously empty, but I am trying to set up a new database based on the current lists using

    const keystone = new Keystone({
    	name: PROJECT_NAME,
    	adapter: new KnexAdapter({ dropDatabase: true })
    });

I went back to a prior branch, hoping to undo the errors (except the dropped DB of course), but the error persists. Any help much appreciated, I’m at a bit of a loss what to look for here.

My current Keystone versions are:


    "@keystonejs/adapter-knex": "^7.0.0",
  "@keystonejs/adapter-mongoose": "^5.2.0",
    "@keystonejs/app-admin-ui": "^5.8.0",
    "@keystonejs/app-graphql": "^5.1.0",
    "@keystonejs/app-next": "^5.1.0",
    "@keystonejs/app-static": "^5.1.0",
    "@keystonejs/auth-password": "^5.1.0",
    "@keystonejs/field-content": "^5.4.0",
    "@keystonejs/fields": "^6.3.0",
    "@keystonejs/fields-markdown": "^5.1.0",
    "@keystonejs/fields-wysiwyg-tinymce": "^5.2.0",
    "@keystonejs/file-adapters": "^5.5.0",
    "@keystonejs/keystone": "^5.5.0",
    "@keystonejs/list-plugins": "^5.1.2",
    "@keystonejs/oembed-adapters": "^5.1.0",

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Vultrazcommented, Apr 3, 2020

@DJonesCadient you’ll need to make sure all your dependencies are updated to latest. especially @keystonejs/keystone and @keystonejs/adapter-knex to 7.0.0 and @keystonejs/fields to 7.0.2.

1reaction
DJonesCadientcommented, Apr 2, 2020

@DJonesCadient I would also. I’m facing the same issue today.

@ejferg Here you go yarn.lock.txt

Read more comments on GitHub >

github_iconTop Results From Across the Web

Postgresql error with Knex Adapter in KeystoneJS 5
Postgresql error with Knex Adapter in KeystoneJS 5: 'Error: Cannot read property 'find' of undefined' · Ask Question. Asked 2 years, 8 months ......
Read more >
[Solved]-Cannot run project anymore with error
[Solved]-Cannot run project anymore with error: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set-postgresql.
Read more >
@keystonejs/adapter-knex - npm
The Knex adapter is a general purpose adapter which can be used to connect to a range of different database backends.
Read more >
Adding A New Property To Mongo After 'Save' In Keystone
I am new to Postgresql more familiar with Mongo but our DevOps Knex Adapter in KeystoneJS 5: 'Error: Cannot read property 'find' of....
Read more >
Prisma | NestJS - A progressive Node.js framework
Prisma currently supports PostgreSQL, MySQL, SQL Server, SQLite, MongoDB and CockroachDB (Preview). While Prisma can be used with plain JavaScript, it embraces ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found