Alias #14

Closed
masylum opened this Issue Apr 26, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@masylum
Owner

masylum commented Apr 26, 2011

In order to save disk space, sometimes people need to name their fields with obscure names.
I think its a good idea to let users define alias for their field names.

MODEL.alias = {
  created_at: 'ca',
  name: 'n'
};

foo.mongo('findOne', {name: 'bar'}, function (err, doc) {
  console.log(doc.name); // => 'bar'
  console.log(doc.created_at); // => 'Jun 12, 2011 ...'
  console.log(doc.n); // => 'bar'
});

This feature if used will add a little overhead to setup the setters/getters on returning elements.

@trollixx

This comment has been minimized.

Show comment Hide comment
@trollixx

trollixx May 3, 2011

Maybe it's better do not allow access by alias and field name at the same time?

trollixx commented May 3, 2011

Maybe it's better do not allow access by alias and field name at the same time?

@masylum

This comment has been minimized.

Show comment Hide comment
@masylum

masylum May 3, 2011

Owner

I have to think a little bit more about this feature. I don´t want to complicate too much the source.

Owner

masylum commented May 3, 2011

I have to think a little bit more about this feature. I don´t want to complicate too much the source.

@masylum masylum closed this Jun 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment