Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: prisma.item.cursorStream is not a function #1

Closed
erikstorli opened this issue Nov 28, 2023 · 5 comments
Closed

TypeError: prisma.item.cursorStream is not a function #1

erikstorli opened this issue Nov 28, 2023 · 5 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@erikstorli
Copy link

This is client.js which I use around my project:

const prisma = require('@prisma/client');
prisma.Decimal.prototype.toJSON = function() {
    return this.toNumber();
}

const { PrismaClient } = prisma;
const cursorStream = require('prisma-cursorstream');

const prismaClient = new PrismaClient().$extends(cursorStream);

module.exports = prismaClient;

Then I initialize the client, and use it like this:

const prisma = require('../client');
const rows = prisma.item.cursorStream({
  select: {
    id: true
  }
});

But I just get TypeError: prisma.item.cursorStream is not a function. What am I doing wrong? findMany works. Using Prisma 5.6.0.

@aularon
Copy link
Contributor

aularon commented Nov 29, 2023

Hello @erikstorli! I believe this issue is because you are using the require syntax. In my usage I have only tested with imports. I will try to replicate the issue locally and see how I can fix exports to make your code work.

@aularon aularon self-assigned this Nov 29, 2023
@aularon
Copy link
Contributor

aularon commented Nov 29, 2023

Hello again @erikstorli! It seems that in the require syntax you only need to make a slight modification:

const cursorStream = require('prisma-cursorstream').default;

and it should work! Please test and let me know.

@aularon aularon added the documentation Improvements or additions to documentation label Nov 29, 2023
@erikstorli
Copy link
Author

Works perfectly, and made the memory usage in the script much better than pagination. Thank you very much!

@aularon
Copy link
Contributor

aularon commented Dec 6, 2023

My pleasure! Happy to read about your experience, as it makes what I'm doing more meaningful.

I documented this in the README file, too. Thank you!

P.S. Do you mind if I use what you wrote as a testimonial in the documentation? Something along the lines of:

Works perfectly, and made the memory usage in the script much better than pagination. — erikstorli

Best!

@erikstorli
Copy link
Author

No problem at all 👍 Thank you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants