Closed richrd closed 3 years ago
Hi sorry I didn't see this before. A couple of notes here:
read
method. If an array is found, could return an array, otherwise return the first element of the array.const record = (await odoo.read('res.partner', 384, ['name','email']))[0]
I will add 2 from above to the next release.
Thank you
Thanks! That workaround is indeed pretty much what I want. I had forgotten that accessing non-existing array indices in JavaScript just returns undefined
anyway. So no need for an if statement. That said I think a readOne
method is probably unnecessary.
I'm proposing to add a
readOne
method that's similar toread
but only accepts a single ID and returns a single result or undefined. It'd be neater to use when just getting a single record without having to then do something likerecord = records[0];
Any thoughts?