The problem I'm trying to solve is: I have a service that generates entities every day. Some of those entities will be new, and some will have already been found in a previous run.
I need to:
- keep the database up-to-date, i.e. containing all the entities that have ever been found
- be able to tell when a new entity is found. Each entity contains a timestamp, so if I can make sure entities aren't over-written, this shouldn't be too hard (I'll just query the database for the entities that were found today and these should be the new ones), so this is what I'm trying to do.
The generated data looks like this
[
{"key": "a",
"foo": "bar",
"timestamp": "EXMAPLE_TIMESTAMP" },
{"key": "b",
"foo": "baz",
"timestamp": "EXMAPLE_TIMESTAMP" }
]
Note: The entities have unique datastore keys
Edit: I tried using Put(), but it just overwrites the entities if their keys already exist, which leads to the timestamps being updated even if the actual content is the same.