What's the difference between putRelation() and addRelation()?


#1

Hi guys

In your documentation, you use addRelation() in the Java code for the graph API overview

But there’s very similar code in the quick start that uses putRelation() instead. What’s the difference? Which should I prefer?

Thanks in advance!


#2

Hi Andrew,

So putRelation() allows you to specify the id of the relation while addRelationI() just lets the id be auto-generated.
You can think of it like deciding wether you want to control the primary key of a traditional SQL table or not.
However, I would recommend using addRelation() as we are likely to remove putRelation() in the future.

Hope that clears things up a bit.


#3

Ah, OK - thanks. Is it the same for putEntity and addEntity too?

Thanks for the quick response,
Andrew


#4

Yes that is correct. The “put” functionality for instances is something we are going to slowly take out.


#5

I think it’s useful to mention that when you do a put (instead of an add), you should expect to get back an existing concept (rather than a newly created one) if a concept with that id already exists.

Although, as @filipe says, please avoid using puts on anything other than Resources. Cause they will very likely be deprecated soon.