Update comment ticket error

I think this is right
response = db.comments.update_one(
{ “_id”: ObjectId(comment_id), “email”:user_email},
{ “$set”: { “text”: text, “data”:date}}
)

however when i try to get the ticket code
it says… Create/Update Comments: Unable to update comment
;/

What is the error in the console when you are trying to get the validation code?

Also, please check if there is sort implemented in the comments function. :slight_smile:

Kanika

Check the name of the field for date!

1 Like

yeah i changed it to “date” but it still didn’t work. I get a new document in compass, but as far as updating it. It doesn’t seem to work ;/

update with date looks OK, but may be insert_one has an error?

Carefully compare your added comment record with existing one. This is were I made mistake - I forgot about ObjectID, for example

I figured it out.

i had this as my pipeline
“”"
pipeline = [
{
‘$match’: {
‘_id’: ObjectId(id)
}
}, {
lookup': { 'from': 'comments', 'let': { 'id': '_id’
},
‘pipeline’: [
{
‘$match’: {
‘$expr’: {
‘$eq’: [
‘$movie_id’, ‘$$id’
]
}
}
}, {
‘$sort’: {
‘field’: -1
}
}
],
‘as’: ‘comments’
}
}
]
“”"
and i changed it to this
pipeline = [
{
“$match”: {
“_id”: ObjectId(id)
}
},
{
lookup": { "from": "comments", "let": {"id": "_id”},
“pipeline”: [
{"$sort": {“date”: -1}},
{"$match": {
“$expr”: {
“$eq”: ["$movie_id", “$$id”]
}
}}
],
“as”: “comments”
}
}
]
still i’d be awesome if i would get an error in the get comment ticket instead of a check ;/ would have saved me loads of time