Unitech / angular-bridge

Link models easily via a REST interface between Mongoose/Node-Express/Angular.js
208 stars 22 forks source link

Hidden Fields get removed on update #14

Closed kentcdodds closed 10 years ago

kentcdodds commented 10 years ago

I have a resource called users which has the following hidden fields:

[
  "hash",
  "salt",
  "connectedAccounts.facebook.token",
  "connectedAccounts.facebook.secret",
  "connectedAccounts.google.token",
  "connectedAccounts.google.secret",
  "connectedAccounts.twitter.token",
  "connectedAccounts.twitter.secret"
]

It looks like when I update the model (specifically at connectedAccounts.facebook.rules) the token and secret for all connectedAccounts gets deleted. Am I using the hide property correctly? If not, what do I need to do?

The reason I suspect hide being related to the issue is that if I remove those fields from the hide property, the token and secret fields are left alone on an update.

I'm guessing it has to do with the fact that in the first scenario, I'm not sending those fields because they're hidden and the client doesn't even have them, so somehow it's interpreted that those fields should be removed. However, hash and salt don't experience the same issue, which is why I'm at a loss... Thanks!

kentcdodds commented 10 years ago

Decided to work around rather than make this work. I now put the stuff I want to be hidden in a property called hidden and I simply hide that. A little wonky, but ultimately makes this easier to deal with.