I have this:
rel Items {
id: int,
pid: int,
ts: long,
}
And this data:
id:int,pid:int,ts:long
1,38961,1310084883
I want to append a new item but only if the id is not in the database
yet. For example, if I send this information:
id:int,pid:int,ts:long
1,0,1310085367
I want the database to remain unaltered. If the database doesn't
contain a tuple with id == 1, then I want the new information to be
added to the database.
Is that possible?
Thanks.
You can achieve this with the help of the minus operator. First, you can
remove the items which are already stored from the incoming dataset, and
then append the remainings to your global variable (store in the example
below):
---
store: Items;
fn AppendNewItems(i: Items)
{
newItems := i - store project(id);
store += newItems;
}
---
Hope this helps.
Regards
Ostap
That was super elegant, thanks a lot!
I had found a terrible solution for a very specific case of this
general problem, and I'm delighted such a simple solution exists.
Again, thanks :-)