I am looking for possible solutions to chain promises just like shown below.
const getDetailsFromDb = await prisma.someTableNames().field()
Because the only possible way I know is as follows:
const SomethingToBeChained = function() {
// where every method of object attached
// to this instance should return this itself
// so other properties attached to it can be accecd.
return this
}
SomethingToBeChained.prototype = {
methodOne: function () { ...do something...; return this }
methodTwo: function () { ...do something...; return this }
}
// now one can do following.
SomethingToBeChained.methodOne().methodTwo()
But prisma client can do both how? Can anyone explain me how this works behind the scene of the prisma
client. How does its structure achieve to call await and chain objects same time?
Only possible way I know ?
const somethingAwaited = (await SomethingToBeChainedIsPromise().wantToChainSomethingButCant()) <--- Ugly
const wantThis = await SomethingToBeChainedIsPromise().wantToChainSomethingButCant()