9
votes

I'm figuring out if it would be easy to move my already existing app towards a Google Cloud Datastore. Currently it exists in MongoDB so it would be from NoSQL to NoSQL, but it does not seem that it would be easy. An example. My app uses a hierarchy of objects which is why I like MongoDB because of its elegance:

{
"_id" : "31851460-7052-4c89-ab51-8941eb5bdc7g",
"_status" : "PRIV",
"_active" : true,
"emails" : [
  { "id" : 1, "email" : "[email protected]", "_hash" : "1514e2c9e71318e5", "_objecttype" : "EmailObj" },
  { "id" : 1, "email" : "[email protected]", "_hash" : "78687668871318e7", "_objecttype" : "EmailObj" }
  ],
"numbers": [
...
],
"socialnetworks": [
...
],
"settings": [
...
]
}

While moving towards Google Cloud Datastore, I can save emails, numbers, socialnetworks, settings, etc as a string, but that defeats the whole purpose of using JSON as I will lose the opportunity to query this. I have a number of tables where I have this issue.

Only solution I see is to move all of these to different entities (tables). But in that case the amount of queries will increase, and therefore also the cost. Other solution might be to keep only arrays of ids and do key-value like resolves on Google Cloud Datastore which are free (except traffic maybe).

What is the best approach here?

2
Could you please show what kind of queries you would like to be able to do? That would be a good start to help you out. - learn2day

2 Answers

8
votes

The transition from Mongo to Google's Datastore would not be trivial. A big part of the reason for this is that Datastore (although technically still NoSQL) is a columnar database whereas Mongo is a traditional NoSQL. Just as SQL databases require a different mindset from NoSQL databases, columnar databases require a different mindset again.

The transition from NoSQL to Datastore would require a comprehensive restructuring of your data.

1
votes

You don't have to save everything in a string. Datastore has what is called Embbebed Entity, which looks very much like in Mongo. Just a full object into another.

Check some library like Objectify which makes it very easy to interact with datastore.