TypeError: ResourceGetter is not a constructor

Expected behavior

No error

Actual behavior

We get a TypeError: ResourceGetter is not a constructor when using ResourceGetter:

const { ResourceGetter } = require('forest-express-sequelize')

const resourceGetter = new ResourceGetter(models.orders, { recordId: orderId })
const order = await resourceGetter.perform()

However I see in the codebase that our syntax looks correct: forest-express-sequelize/databases.test.js at 7cceb40153165b65089df011ed4acd02fbcdb97a · ForestAdmin/forest-express-sequelize · GitHub

Failure Logs

Nothing more than the TypeError

Context

Please provide any relevant information about your setup.

  • forest-express-sequelize: 6.6.3
  • forest-express: 7.9.4
  • Express Version: 4.17.1
  • Sequelize Version: 5.19.6
  • Database Dialect: Postgres
  • Database Version: -
  • Project Name: UrbanCampus - Platform
  • Environment: all of them

It’s pretty urgent for us as we noticed the issue on prod and just upgraded from v5 to v6 so we’d like to avoid a rollback… Thanks

Hi @cberez,

Could you check that you required the ResourceGetter properly at the beginning of the file on which the error is happening?

{ ResourceGetter } = require('forest-express-sequelize');

Hi @anon37102731,

Here’s the require line (updating the original message too):

const { ResourceGetter } = require('forest-express-sequelize')

To be more precise: it’s an old code that’s been there for some time and used to work, now we get the TypeError, it seems since we upgraded to 6.6.3

@cberez I just looked at the code and the ResourceGetter service is not exposed through forest-express-sequelize. It’s only intended to be used internally.

However, a RecordGetter is exposed to perform the kind of record retrieval logic you’re trying to build. You can find several example of this RecordGetter usage on our documentation.

I hope you’ll find what you need in there!

Ah must’ve been hidden on latest versions, our code dates back to v4

Thanks I’ll have a look to the RecordGetter