These are chat archives for Automattic/mongoose

20th
Jun 2016
Balasubramanian.A
@0xnandhi
Jun 20 2016 14:41
Hi All, i am mapping a SQL DB data to mongo DB. I am using Mongoose. I am unable to map a BigInt(20) to MongoDB using mongoose. Its rounding off the number . Can any one please help me .. am desperate.. to complete this task
Daniel Acuña
@moustacheful
Jun 20 2016 15:58
anyone with experience with model discriminators that can lend a hand?
Daniel Acuña
@moustacheful
Jun 20 2016 16:42
or anyone know a good way to provide a schema wih conditional subdocument schema based on a document property?
e.g. a given model has different data subdocument schema types depending on the model's typeproperty
LeonineKing1199
@LeonineKing1199
Jun 20 2016 16:43
Can't you just define the sub-document and make it not required?
Daniel Acuña
@moustacheful
Jun 20 2016 16:43
I can do that, or use mixed, but i'd like to keep it always bound to data
instead of dataForType1, dataForType2
LeonineKing1199
@LeonineKing1199
Jun 20 2016 16:43
Hmm...
Daniel Acuña
@moustacheful
Jun 20 2016 16:43
even an enum for schema types would be good
LeonineKing1199
@LeonineKing1199
Jun 20 2016 16:44
What if you used two different documents and left the conditional logic up to your application?
Daniel Acuña
@moustacheful
Jun 20 2016 16:44
like, data: [SchemaForType1,SchemaForType2]
that could do.
I was trying discriminators, but I was expecting them to preserve the discriminator values even on the 'base' model
instead it gives you multiple models
which could be useful, but at the same time it would force me to repeat a bunch of code
LeonineKing1199
@LeonineKing1199
Jun 20 2016 16:46
I feel like the gigantic SQL queries taught us all a valuable lesson, keep logic at the application level XD
But that's just my opinion on the subject.
Daniel Acuña
@moustacheful
Jun 20 2016 16:47
so far it seems like a better idea to leave it as mixed and add some other validation utility to enforce schemas
well, with mongoose it is at application level, isn't it?
LeonineKing1199
@LeonineKing1199
Jun 20 2016 16:51
I'm not sure.
I try to use as little of mongoose as is possible :P
Daniel Acuña
@moustacheful
Jun 20 2016 16:52
well, the approach i'm aiming at right now would leave mongoose to the side
since it can't adhere to what I need right now
I would have to just set data as Mixed
and then validate on my own. :v
LeonineKing1199
@LeonineKing1199
Jun 20 2016 16:54
#GoodEnough
XD