bulbs icon indicating copy to clipboard operation
bulbs copied to clipboard

Determining whether VertextProxy.get_or_create() created a vertex or or not

Open ghost opened this issue 12 years ago • 1 comments

I'm looking for a way of being able to call VertexProxy.get_or_create() and inspect whether it resulted in a new vertex being created.

I'm wondering what you suggest for this, and whether this might be a useful addition to bulbs?

One solution might be to include a callable as a value in _data and check whether the callable was invoked by .create(_data) inside get_or_create(). Another possible solution might be to modify get_or_create() to add an 'is_new' attribute to the vertex instance. But I worry this might get cached or that this attribute might get stored on the db if save() is called (I haven't delved far enough into bulbs to know this off-hand).

ghost avatar Jul 24 '13 11:07 ghost

To generalize this so that it works across all backends, regardless of how get_or_create() is implemented in the future, it would probably be best to store a value in the Result object indicating whether an element was CREATED, READ, UPDATED, DELETED.

espeed avatar Aug 03 '13 00:08 espeed