I am storing the data for my app in Google’s NDB, but am confused as to what architecture to use. The app data is mostly text based, but has some non-text properties like DateTimeProperty
, FloatProperty
and one or two BooleanProperty
‘s.
I could store each property correctly (e.g. a datetime
is stored as a DateTimeProperty
), or I could already package all the data up as a JSON object and store it as a JsonProperty
.
Storing everything as a JsonProperty
gives the benefit of taking up less space (there’s a compress
flag that causes the content to be gzipped), but taking this approach makes it harder to search the database with query()
.
Which approach is better to take?
3
Personally, I’d go with using regular data types instead of serialising it to JSON then storing that instead as that is the most natural way to go about it plus you can index it.
Storing JSON objects have its uses too, especially if you want to make quick canned responses or if the one processing your data can readily read JSON(i.e. nodejs and its ilk) and the need to query this field doesn’t exist(JSONProperty is stored as a blob, good luck indexing that)