janhommes / o.js

o.js - client side oData lib.
https://janhommes.github.io/o.js/example/
MIT License
238 stars 57 forks source link

Patch does not support singleton models #82

Closed kartikjain12 closed 5 years ago

kartikjain12 commented 5 years ago

In order to use patch, o.js requires you to have "(id)" in the path. This works most of the time but if you want to patch a singleton model and don't provide "(id)" in the path then the o data client throws an exception "Bulk updates are not supported. You need to query a unique resource with find() to patch/put it." For example in my javascript code the following does not work

var path = `${Base}${endPoint}`
o(path).patch(entity).save(function() {
        resolve()
      }

but this will

var path = `${Base}${endPoint}(${entity.Id})`
o(path).patch(entity).save(function() {
        resolve()
      }
janhommes commented 5 years ago

yes, that is an issue. I am currently working on a rewrite of o.js. The code is very old and doesn't fit today's needs. Therefore I will not fix that but I will inform you as soon as the new version is available.

kartikjain12 commented 5 years ago

Thanks for the update @janhommes

janhommes commented 5 years ago

https://github.com/janhommes/o.js/tree/feature/version-1.0.0-rc.1

Here is the new version build in typescript. I will create a new npm package and an announcment out of it later that day.

janhommes commented 5 years ago

83