These are chat archives for Automattic/mongoose

12th
Mar 2018
Prasad nv
@prasad47
Mar 12 2018 05:25 UTC
@lineus hi Kev
is there any solution to my problem
?
any suggestions plz
Ghost
@ghost~5928d90bd73408ce4f629b9e
Mar 12 2018 07:07 UTC
IS THERE ANY TUTORIAL FOR MERN AUTHENTICATION THAT'S NOT USING MONGOOSE? MONGOOSE SHOULD DIE DIE DIE
Chris Hurst
@ytsruh
Mar 12 2018 07:16 UTC
@2HexGFX_twitter I think you're in the wrong place for comments like that :) but as for auth tutorials, mongoose doesnt have anythign todo with auth - you can just use the mongodb driver in its place
Chris Hurst
@ytsruh
Mar 12 2018 07:21 UTC
or sequelize if you want to use mysql :)
Prasad nv
@prasad47
Mar 12 2018 07:25 UTC
@ytsruh is @lineus online ?
Chris Hurst
@ytsruh
Mar 12 2018 07:26 UTC
@prasad47 no idea mate sorry. He's normally pretty active but I think he's based in the US so it might be a few horus before he replies
@ytsruh can I help?
Prasad nv
@prasad47
Mar 12 2018 07:35 UTC
@ytsruh he is dealing with an issue mate
Automattic/mongoose#6215
Could you take a look
and suggest if you can ... Plz
Kev
@lineus
Mar 12 2018 09:10 UTC
sorry I slept in until 5am today :)
@prasad47 did you ever enable debug on mongoose? what is the last mongoose debug log right before that error message?
Kev
@lineus
Mar 12 2018 09:20 UTC
oh wait, we just switched to DST. I got up at 4 according to my internal clock ( just like every other day.) Damn. So much for sleeping in.
Chris Hurst
@ytsruh
Mar 12 2018 09:25 UTC
@prasad47 does the document actually save? or not?
Chris Hurst
@ytsruh
Mar 12 2018 11:21 UTC
@prasad47 just out of curisoisty what do you get when you console.log(obj) ?
Prasad nv
@prasad47
Mar 12 2018 13:36 UTC
@ytsruh Document is not saving
it is consoling the my dynamic object which is sent as payload to the api from client
like it posted in The Ticket
@lineus i just saw Your Messages Lineus
Chris Hurst
@ytsruh
Mar 12 2018 14:15 UTC
@prasad47 can you create new records?
Prasad nv
@prasad47
Mar 12 2018 14:25 UTC
yes @ytsruh @lineus i can able to create the other records properly and Successfully
i tested few other .save methods
they did good
Chris Hurst
@ytsruh
Mar 12 2018 14:26 UTC
@prasad47 so updating an existing one is the issue?
Prasad nv
@prasad47
Mar 12 2018 14:28 UTC
@ytsruh @lineus no .. update is happening fine
but the ..save method while saving this object is raising the above error
Chris Hurst
@ytsruh
Mar 12 2018 14:29 UTC
@prasad47 which object? A new 'cart'?
do you have the full code somehwere i could look at?
Prasad nv
@prasad47
Mar 12 2018 14:30 UTC
you see it in the ticket right
the model and controller code
i posted it on github issue actually
Chris Hurst
@ytsruh
Mar 12 2018 14:31 UTC
@prasad47 was hoping to see the endpoint/route and the full code including imprts/exports etc
Prasad nv
@prasad47
Mar 12 2018 14:31 UTC
can you come to skype possible
so i can screen share
Chris Hurst
@ytsruh
Mar 12 2018 14:33 UTC
sorry dont have it. I'll try to recreate it now and see what I do
im running 3.8.8 too
Prasad nv
@prasad47
Mar 12 2018 14:34 UTC
do you have team viewer
?
uberconfrence\
Chris Hurst
@ytsruh
Mar 12 2018 14:35 UTC
@prasad47 sorry im on a work PC, locked to use webex only
Prasad nv
@prasad47
Mar 12 2018 14:37 UTC
@ytsruh Looks Like Webex is a Premium one
ok
Kev
@lineus
Mar 12 2018 14:41 UTC
hey @ytsruh what version of mongodb server are you running?
Chris Hurst
@ytsruh
Mar 12 2018 14:41 UTC
@lineus 3.2.18
Prasad nv
@prasad47
Mar 12 2018 14:41 UTC
3.4.6
Kev
@lineus
Mar 12 2018 14:42 UTC
I tried to connect mongoose@3.8.8 to 3.02 and above and it complained about the server verson. but it works for you?
@ytsruh ^
Prasad nv
@prasad47
Mar 12 2018 14:43 UTC
yes it is my server version is 3.4.6 i can able to run CRUD properly
but this error happening only with this Schema it self
Hi @lineus welcome back man
Kev
@lineus
Mar 12 2018 14:45 UTC
hey @prasad47. sorry you're still fighting with this.
Chris Hurst
@ytsruh
Mar 12 2018 14:46 UTC
@lineus nah it throws an error with mongoose 3.8.8 (no bson module)
Prasad nv
@prasad47
Mar 12 2018 14:46 UTC
Yes unfortunately .. but i am one Issue way to Get Happy
yes that is a Fixable one quickly
i fixed that but that dont effect the mongoose as per my knowledge
Chris Hurst
@ytsruh
Mar 12 2018 14:47 UTC
@lineus @prasad47 confident this is a versioning error here
Prasad nv
@prasad47
Mar 12 2018 14:51 UTC
is it possbiel for any one of you to join cisco webex .. iam on trail version
i can screen share and show you guys
Chris Hurst
@ytsruh
Mar 12 2018 14:51 UTC
i can later, just waiting for someone to drop by my desk
Prasad nv
@prasad47
Mar 12 2018 14:51 UTC
soryy guys if iam pushing you .. i just signed up
for trailversion
Kev
@lineus
Mar 12 2018 14:55 UTC
prasad, can you console.dir(obj.toObject) before it hits save? I'm curious what your bson objectid looks like.
Prasad nv
@prasad47
Mar 12 2018 14:55 UTC
ok sure
Kev
@lineus
Mar 12 2018 14:56 UTC
I couldn't get mongoose@3.8.8 to connect to any instances, but when I inspected the ID that got created before the save it looks like this:
{ name: 'kevin', _id: ObjectID { _bsontype: 'ObjectID', id: 'Z¦”•ê\u0005˜!ç£Vý' } }
Chris Hurst
@ytsruh
Mar 12 2018 14:57 UTC
@prasad47 no issues mate, im keen to help just hard for me to do so in the office
Prasad nv
@prasad47
Mar 12 2018 14:57 UTC
oh ok .... got it ...
Kev
@lineus
Mar 12 2018 15:00 UTC
@prasad47 also, earlier you said the bson error was fixable. can you elaborate on exactly how you fixed it?
Prasad nv
@prasad47
Mar 12 2018 15:05 UTC
happening When consoled (options) {\n return this.$toObject(options);\n}'
Console.dir(obj.toObject);
@lineus
i followed this post to fix the bson error
Kev
@lineus
Mar 12 2018 15:09 UTC
sorry, I forgot to put the parens in my question above. toObject is a function so its console.dir(obj.toObject())
Prasad nv
@prasad47
Mar 12 2018 15:11 UTC
i executed the above code .. it is returning the payload object i sent to save
Like this
{
"displayName": "Desktop Cart",
"payment": {
"method": "Cash",
"status": "Paid"
},
"referralServer": {
"name": "none"
},
"analytics": {
"referer": "self",
"userAgent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36"
},
"customer": {
"userId": "58d5d5dssd4d55d4d5d5d45d5",
"email": "nvprasad@gmail.com",
"firstName": "Prasad",
"lastName": "NV",
"phone": 99999999999
},
"system": {
"isDeleted": false,
"isEnabled": true,
"dateUpdated": "2018-03-07T17:54:02.294Z",
"dateCreated": "2018-03-07T17:54:02.294Z"
}
}
Kev
@lineus
Mar 12 2018 15:18 UTC
like that? or exactly that? because that's too many characters for an id.
$ x='58d5d5dssd4d55d4d5d5d45d5'
$ echo -n ${x} | wc -c
      25
$
Chris Hurst
@ytsruh
Mar 12 2018 15:21 UTC
@lineus should be 24 right?
Kev
@lineus
Mar 12 2018 15:22 UTC
as far as I know. but I just got off the treadmill a few minutes ago, anything is possible.
Chris Hurst
@ytsruh
Mar 12 2018 15:22 UTC
@lineus hahaha!
Prasad nv
@prasad47
Mar 12 2018 15:23 UTC
@ytsruh @lineus let me show the real one guys i am sorry for that this chat will be forwarded to my client
it is gonnabe concern to me but i have to do it now i think
let me share in a sec
Kev
@lineus
Mar 12 2018 15:24 UTC
you don't have to share it, just make sure it's only 24 chars and valid bson
Prasad nv
@prasad47
Mar 12 2018 15:25 UTC
it is valid bson 5aa178baa53c440013ada1dc
i am 100 % sure this is the one
Kev
@lineus
Mar 12 2018 15:32 UTC
have you looked into the validate command in mongodb @prasad47 ?
Prasad nv
@prasad47
Mar 12 2018 15:34 UTC
not but we are using similiar
mongoose.Types.ObjectId.isValid(id)
let me know when you go through it
i can delete it ..
Kev
@lineus
Mar 12 2018 15:38 UTC
you can delete it, it's the same id that you pasted here
can you open a mongo shell to your db and do a db.collection.find{ _id: 'that_ID' }) and see if that returns the doc?
for whatever your collection is named
Prasad nv
@prasad47
Mar 12 2018 15:41 UTC
sure
Prasad nv
@prasad47
Mar 12 2018 15:47 UTC
it is returning the doc
Kev
@lineus
Mar 12 2018 15:51 UTC
ok, and are you still upgraded to mongoose@5.0.9?
Prasad nv
@prasad47
Mar 12 2018 15:52 UTC
yes "mongoose": "^5.0.9",
mettjus
@mettjus
Mar 12 2018 22:26 UTC
hi! i have a number of entity types (collections) and i want to be able to represent connections between instances of any type. connections should be bidirectional. i am thinking about a "connections" collection that contains some linking props (i.e. a_collection, a_id, b_collection, b_id). is it somehow manageable with mongoose (i imagine populating a "related_items" virtual prop or something like that) or should i approach it at another level/in a different way?
mettjus
@mettjus
Mar 12 2018 22:33 UTC
actually thinking about using an instance method