How to get last message from chat conversation in mongodb

I have tried to get last message in chat between users. Below is my collections in my document. { “toUser”:123,”fromUser”:456,”message”:”1 from suresh”,”timeStamp”:”2019-10-09 16:39:14:1414 PM +05:30″, “toUser”:456,”fromUser”:123,”message”:”Man super man “,”timeStamp”:”2019-10-09 16:43:09:0909 PM +05:30″, “toUser”:456,”fromUser”:123,”message”:”Kk”,”timeStamp”:”2019-10-09 18:31:12:1212 PM +05:30″ “toUser”:456,”fromUser”:123,”message”:”It working man”,”timeStamp”:”2019-10-09 18:31:18:1818 PM +05:30″ “toUser”:456,”fromUser”:123,”message”:”2″,”timeStamp”:”2019-10-09 18:31:21:2121 PM +05:30″ “toUser”:101,”fromUser”:123,”message”:”Kk”,”timeStamp”:”2019-10-09 18:31:12:1212 PM +05:30″ } and i used mongo…

Save dots ‘.’ in key as a field in MongoDB using SpringBoot

I have json data where the key contains dots as ‘123.456’ and value as object. { “models”: { “123.456”: [{ “key1”: “value1”, “key2”: “value2” }] } } I am getting an mapping exception when trying to save the object in MongoDB as following org.springframework.data.mapping.model.MappingException: Map key 123.456 contains dots but no replacement was configured!Make sure…

why mongodb speed of sort by subdocument field so slow?

my test collection has these fields { “block_number”: 123123, “value”: 555.55555 “transfers”: [ { “from”: “foo1”, “to”: “bar1”, “amount”: 111.111 }, { “from”: “foo2”, “to”: “bar2”, “amount”: 222.222 }, … { “from”: “foo3”, “to”: “bar3”, “amount”: 100.100 }, ] }, … { … } and I made indexes like this (at python code) tx_collection.create_index(“block_number”) tx_collection.create_index(“transfers.amount”)…

MongoDB not updating in node js using graphql

I’m doing an update mutation in graphql in front end mutation updateSetting($updateSetting:CoSettingInput,$id:String) { updateConSettings(input:$updateSetting,settingId:$id){ _id Local Token Credentials Port Host Auth } } Variables passed from front end for graphql { “updateSetting”: { “Local ” :”asdasdkk” “Token”:”asdasdkk” “Credentials”:”asdasdkk” “Port”:”asdasdkk” “Host”:”asdasdkk” “Auth” :”asdasdkk” }, “id”: “5d96e98e7a921f0414619ad1” } Backend MongoDB quering in node js input CoSettingInput{ Local…

mongodb doesn’t work on latest Mac OS(10.15)

I updated to Mac 10.15 today. When I run mongod the terminal: ➜ /Users/william > mongod 2019-10-08T17:02:44.183+0800 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify –sslDisabledProtocols ‘none’ 2019-10-08T17:02:44.209+0800 I CONTROL [initandlisten] MongoDB starting : pid=43162 port=27017 dbpath=/data/db 64-bit host=Williams-MacBook-Pro-6.local 2019-10-08T17:02:44.209+0800 I CONTROL [initandlisten] db version v4.0.3 2019-10-08T17:02:44.209+0800 I CONTROL [initandlisten] git…