This time we will look at the differences in updating records
between MongoDB and the MySQL Document Store. Syntactically
they are pretty different. I am still following the
Getting Started With MongoDB article for
example queries.
Updating Records
In Mongo we update thusly:
> db.restaurants.update(
... { "name" : "Juni" },
... {
... $set: { "cuisine" : "American (new)" },
... $currentDate: { "lastModified" : true }
... }
... )
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1
})
>
The same update in the MySQL Document Store can be a lot
different. We could update using SQL or NoSQL. I
would like to update the document with the change to the cuisine
and …
Showing entries 1 to 2
Jun
17
2018
Jun
15
2018
Last time I was stumped by the MongoDB $gt:
operator. I wanted to look for restaurants in a certain
Manhattan burough OR in a zipcode greater than a certain
zipcode. Well, I was getting different results between
Mongo and MySQL.
To > or Not To >, That Is the Query
Lets say we have three records with the same key but the values
are 1, 2, and "3". Yup, you got it two numerics and one
string. I would expect schema less data to be free flowing,
not typed, and pretty much a free for all. Whoops. Bad
assumption on my part for Mongo use.
I added three JSON documents into Mongo as can be seen
below:
Our three documents with the values of 1, 2, … |
Showing entries 1 to 2