These are chat archives for Automattic/mongoose

28th
Sep 2017
Arye Shalev
@pantchox
Sep 28 2017 00:27
Hi, i am a bit lost with _id and id options. my issue is that there are times when the client needs to generate the id and sometimes the server. when the server receives the POST request for example, if the id is not included (even if included.. ) then automatically the _id is generated in the db and in the response i get it as id (great!). but when the client sends id it just doesnt work, so maybe i need to add it to my Schema? but if i add _id it means i need the client to send _id which i can't do it (client source), how can i let the client send a normal id (which is ObjectId valid string) and creates a _id? and if i don't send it will autogenerate it, hope it makes sense!?
asim009
@asim009
Sep 28 2017 12:17
Hi All, I am new to mongoose and started learning the basic. I was struck in between
{
"_id" : ObjectId("59ca65a2289f6b3bb054f78f"),
"dueDate" : ISODate("2017-07-07T00:00:00Z"),
"remarks" : "2017-07-07",
"enquiryDate" : ISODate("2017-07-07T00:00:00Z"),
"date" : ISODate("2017-07-07T00:00:00Z"),
"enquiryCode" : "5005",
"details" : [
{
"meterialCode" : "2017-07-07",
"meterialName" : "2017-07-07",
"mtype" : "2017-07-07",
"unit" : "2017-07-07",
"qty" : 2,
"remarks" : "2017-07-07",
"price" : 10,
"_id" : ObjectId("59ca65a2289f6b3bb054f791")
},
{
"meterialCode" : "2017-07-07",
"meterialName" : "2017-07-07",
"mtype" : "2017-07-07",
"unit" : "2017-07-07",
"qty" : 7,
"remarks" : "2017-07-07",
"price" : 10,
"_id" : ObjectId("59ca65a2289f6b3bb054f790")
}
],
"suppliers" : [
{
"_id" : "59ca49d4038aa708f380f5e6"
},
{
"_id" : "59ca495b038aa708f380f5e5"
}
],
"__v" : 0
}
above is my code.How can i get the records with supplier._id
?
any help will be helpful to me
thank you
Dennis Belany
@azarus
Sep 28 2017 21:08
okay
aren't iso dates stored as 64bit integers?
in bson
just because... $divide only supports numeric types, not date and int
so what