Hi all, I'm running into an issue that seems to ha...
# orm-help
m
Hi all, I'm running into an issue that seems to have come after I updated my @prisma/cli and @prisma/client to the latest version. Here is the code for the query in question:
Copy code
const nextAcctNum = async (state, type, ctx) => {
	const prefix = state + "-" + (type === "Residential" ? "R" : "C") + "-";
	highAcct = await ctx.prisma.account.findMany({
		where: {
			acct_num: {
				startsWith: prefix,
			},
		},
		orderBy: { acct_num: "desc" },
		first: 1,
	});
	const highAcctNum = highAcct[0].acct_num;
	let num = Number(highAcctNum.substr(5)) + 1;
	let newAcctNum = prefix + num;
	console.log("New Account Number: ", newAcctNum);
	return newAcctNum;
};

module.exports = { nextAcctNum };
This used to work fine and return the highest account number. Now when I run it, I get this error:
Copy code
Error:
Invalid `prisma.account.findMany()` invocation in
C:\Users\...\src\nextacctnum.js:3:38

{
  where: {
    acct_num: {
      startsWith: 'AZ-R-'
    }
  },
  orderBy: {
    acct_num: 'desc'
  },
  first: 1
  ~~~~~
}

Unknown arg `first` in first for type Account. Did you mean `cursor`? Available args:
type findManyAccount {
  where?: AccountWhereInput
  orderBy?: AccountOrderByInput
  cursor?: AccountWhereUniqueInput
  take?: Int
  skip?: Int
}
Does anyone have any idea why I'm getting this error now?
u
Just read the error. Use
cursor
or
take
instead of
first
m
is there documentation on cursor? Does it work the same as first? If so, how does last work now?
m
Thank you @Ugogo, this is exactly what I needed!
👌 1