hoodiehq-archive / hoodie-plugins-api

:no_entry: part of hoodie-server now
http://github.com/hoodiehq/hoodie-server
Apache License 2.0
13 stars 5 forks source link

object passed to 'change' event callback has no name & no type attribute #8

Open gr2m opened 11 years ago

gr2m commented 11 years ago

passed object looks like this:

{ _rev: '2-55c9b15a13f8a27d99af6e1841f27e78',
  password_scheme: 'pbkdf2',
  iterations: 10000,
  name: undefined,
  type: undefined,
  roles: [],
  createdAt: '2013-07-22T19:28:50.364Z',
  updatedAt: '2013-07-22T19:28:50.364Z',
  derived_key: 'f2421774b58d5058e8c29c7eb2a92e3cc2e8b53e',
  salt: '434ce68d7f972ab8aa20c6deaf6ef586' }

note that both type & name are undefined, but they shouldn't.

Also note that there is no _id attribute.

gr2m commented 11 years ago

@caolan this one is a blocker, because I cannot differentiate between the different types.

gr2m commented 11 years ago

type & name are there now. What about the _id attribute? Did you leave it out on purpose?

caolan commented 11 years ago

Well, the id would be the same as name in this case. do you think we should also have the id property?

On 2 August 2013 12:28, Gregor Martynus notifications@github.com wrote:

type & name are there now. What about the _id attribute? Did you leave it out on purpose?

— Reply to this email directly or view it on GitHubhttps://github.com/hoodiehq/hoodie-plugins-api/issues/8#issuecomment-22000155 .

gr2m commented 11 years ago

I mean the original CouchDB _id attribute, do you leave it out on purpose?

in hoodie.js, I set id to the uuid only. Shall we do the same for the worker API?

So if the user doc looks like this:

{
   "_id": "org.couchdb.user:user/test",
   "_rev": "3-066bdcd1e13b91533ec8b17e0926459e",
   "name": "user/test",
   "type": "user",
   "roles": [
   ],
   "ownerHash": "1132235",
   "database": "user/1132235",
   "updatedAt": "2013-08-02T11:28:51.741Z",
   "createdAt": "2013-08-02T11:28:51.741Z",
   "signedUpAt": "2013-08-02T11:28:51.741Z"
}

the passed object to a change handler would be

{
   "_rev": "3-066bdcd1e13b91533ec8b17e0926459e",
   "name": "user/test",
   "type": "user",
   "id": "test",
   "roles": [
   ],
   "ownerHash": "1132235",
   "database": "user/1132235",
   "updatedAt": "2013-08-02T11:28:51.741Z",
   "createdAt": "2013-08-02T11:28:51.741Z",
   "signedUpAt": "2013-08-02T11:28:51.741Z",
   "derived_key": "65ec0624e84ef73d53fc45339ccf4c8d81836cad",
   "salt": "c31a6326d781c889226cff452bbdf699"
}
gr2m commented 11 years ago

I think we can also leave out the name property, right?

I se a potential problem if people will want to set a custom name property, but it's a problem when it's a problem. I think that for custom properties on _users docs I'd use a special $properties property or something, and enforce that with a _design doc, so that they can't mess things up.