I'd like to simply update that record and bump pla...
# orm-help
r
I'd like to simply update that record and bump plays +1 each time a user plays the video
a
I dunno if you can do this using only prisma but if you have a API in front of prisma, then obviously you can just increment that counter and expose that counter as a
Long
(or
Int
) to prisma
I guess your frontend can also do a mutation after your query
r
yeah heres what I have, I'm not using an api in front, but you're right that may make more sense
Copy code
this.prisma.feeds({
				first: 1,
				where: {
					episode: this.episode
				}
			}).then(feed => {
				this.prisma.updateFeed({
					where: {
						id: feed[0].id
					},
					data: {
						plays: feed[0].plays ++
					}
				})
			})
btw this is apart of a class which is why there is the this keyword
j
You shouldnt do this. Self-referential updates are problematic at scale. You would have to lock down the db somehow and make sure that no writes are being made in the time between value read and new value write
👍 1
Instead, create a new type called "FeedPlay" or something similar and just create a new one for every play. Make sure it has a relation to the Feed in question
This gives you the bonus of ⚠️ ≥≥≥≥BIG DATA≤≤≤≤≤≤ ⚠️ later when you're doing analytics and/or data mining
r
Hmm. That’s a good point.
So in your note above are you suggesting something like prisma bindings instead of prisma client ?