Increase current field value in a batch mutation

prisma

#1

With this schema:

type Section {
	id: ID! @unique
	index: Int!
    course: Course!
    title: String!
}

I’d like to increase the index field for each section greater than equal the toIndex value. Like this:

await ctx.db.mutation.updateManySections({
	where: {
		index_gte: toIndex,
		course: {
			id: courseId
		}
	},
	data: {
		index: currentFieldIndex + 1 // HERE
	}
});

Obviously, currentFieldIndex doesn’t exists. Is there any way I can achieve that?


#2

There is no way to accomplish what you are looking for yet.
Once atomic operations are added, you will be able to update the value for integers in an atomic fashion.