field name aliases?

1,590 views
Skip to first unread message

mgutz

unread,
Mar 22, 2012, 10:39:21 PM3/22/12
to mongoo...@googlegroups.com
Is there a way to specify the collection field name in a schema? The long descriptive field names in code are helpful but are starting to eat up bytes on our small VPS.

Aaron Heckmann

unread,
Mar 26, 2012, 2:21:28 PM3/26/12
to mongoo...@googlegroups.com
new Schema({ .. }, { collection: 'yourcollectionname' })

On Thu, Mar 22, 2012 at 10:39 PM, mgutz <mario.l....@gmail.com> wrote:
Is there a way to specify the collection field name in a schema? The long descriptive field names in code are helpful but are starting to eat up bytes on our small VPS.

--
http://mongoosejs.com
http://github.com/learnboost/mongoose
You received this message because you are subscribed to the Google
Groups "Mongoose Node.JS ORM" group.
To post to this group, send email to mongoo...@googlegroups.com
To unsubscribe from this group, send email to
mongoose-orm...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/mongoose-orm?hl=en



--
Aaron



mgutz

unread,
Mar 26, 2012, 5:39:50 PM3/26/12
to mongoo...@googlegroups.com
Field names?

I tried new Schema({userName: String, description: String}, {userName: "u", description: "d"});

The collection still has "userName" and "description" fields instead of "u" and "d"

On Monday, March 26, 2012 11:21:28 AM UTC-7, Aaron Heckmann wrote:
new Schema({ .. }, { collection: 'yourcollectionname' })

On Thu, Mar 22, 2012 at 10:39 PM, mgutz  wrote:
Is there a way to specify the collection field name in a schema? The long descriptive field names in code are helpful but are starting to eat up bytes on our small VPS.

--
http://mongoosejs.com
http://github.com/learnboost/mongoose
You received this message because you are subscribed to the Google
Groups "Mongoose Node.JS ORM" group.
To post to this group, send email to mongoo...@googlegroups.com
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/mongoose-orm?hl=en

Aaron Heckmann

unread,
Mar 26, 2012, 6:56:44 PM3/26/12
to mongoo...@googlegroups.com
oh right. sorry. no that option doesn't exist.


For more options, visit this group at
http://groups.google.com/group/mongoose-orm?hl=en



--
Aaron



Daniel Baulig

unread,
Mar 27, 2012, 4:52:28 AM3/27/12
to mongoo...@googlegroups.com
I guess you could make the fields using the shortnames and setup
virtuals with the long names mapping to the short attribute names:

var schema = new Schema({ s: String, n: Number, b: Boolean});

schema
.virtual('aString')
.get(function () {
return this.get('s');
})
.set(function (v) {
return this.set('s', v);
});

You could still use the short names in code aswell, but at least you
don't have to.

Regards,
Daniel

On 03/27/2012 12:56 AM, Aaron Heckmann wrote:
> oh right. sorry. no that option doesn't exist.
>
> On Mon, Mar 26, 2012 at 5:39 PM, mgutz<mario.l....@gmail.com> wrote:
>
>> Field names?
>>
>> I tried new Schema({userName: String, description: String}, {userName:
>> "u", description: "d"});
>>
>> The collection still has "userName" and "description" fields instead of
>> "u" and "d"
>>
>> On Monday, March 26, 2012 11:21:28 AM UTC-7, Aaron Heckmann wrote:
>>
>>> new Schema({ .. }, { collection: 'yourcollectionname' })
>>>
>>> On Thu, Mar 22, 2012 at 10:39 PM, mgutz wrote:
>>>
>>> Is there a way to specify the collection field name in a schema? The long
>>>> descriptive field names in code are helpful but are starting to eat up
>>>> bytes on our small VPS.
>>>>
>>>> --
>>>> http://mongoosejs.com

>>>> http://github.com/learnboost/**mongoose<http://github.com/learnboost/mongoose>


>>>> You received this message because you are subscribed to the Google
>>>> Groups "Mongoose Node.JS ORM" group.
>>>> To post to this group, send email to mongoo...@googlegroups.com
>>>> To unsubscribe from this group, send email to

>>>> mongoose-orm+unsubscribe@**googlegroups.com<mongoose-orm%2Bunsu...@googlegroups.com>


>>>> For more options, visit this group at

>>>> http://groups.google.com/**group/mongoose-orm?hl=en<http://groups.google.com/group/mongoose-orm?hl=en>
>>>>
>>>
>>>
>>>
>>> --
>>> Aaron
>>> @aaronheckmann<https://twitter.com/#!/aaronheckmann>

Aaron Heckmann

unread,
Mar 27, 2012, 7:16:14 AM3/27/12
to mongoo...@googlegroups.com


On Tue, Mar 27, 2012 at 4:52 AM, Daniel Baulig <daniel...@gmx.de> wrote:
I guess you could make the fields using the shortnames and setup virtuals with the long names mapping to the short attribute names:

good suggestion. 

--
Aaron



Aaron Heckmann

unread,
Mar 28, 2012, 8:45:44 AM3/28/12
to mongoo...@googlegroups.com
Though the shortfall is querying by virtuals is not supported.

mgutz

unread,
Mar 30, 2012, 10:24:19 AM3/30/12
to mongoo...@googlegroups.com
FYI, Kevin Ingersoll sent an email pointing to Alias-Field-Mongoose-plugin on Github 
Reply all
Reply to author
Forward
0 new messages