# Create vs Update operations

**URL:** <https://discuss.aerospike.com/t/create-vs-update-operations/560>\
**Category:** Node.js Client\
**Created:** [November 28, 2014, 12:23pm UTC](https://discuss.aerospike.com/t/create-vs-update-operations/560 "2014-11-28T12:23:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![VikramTiwari](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/vikramtiwari/32/97_2.png) [@VikramTiwari](https://discuss.aerospike.com/u/VikramTiwari)\
**Post date:** [November 28, 2014, 12:23pm UTC](https://discuss.aerospike.com/t/create-vs-update-operations/560/1 "2014-11-28T12:23:28Z")

</div>

Increment operator functions as follows:

input: `op.incr('bin',1)` if the bin doesn’t exists, create bin and put value as 1 else update bin’s value as +1

This works fine. But the callback value that i get for the operations is not unique to the operation. Or is it and i am unable to identify the same?

---

<div class="post-metadata">

**Author:** ![gayathri](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@gayathri](https://discuss.aerospike.com/u/gayathri)\
**Post date:** [December 2, 2014, 11:24am UTC](https://discuss.aerospike.com/t/create-vs-update-operations/560/2 "2014-12-02T11:24:02Z")

</div>

When you say, callback value for the operation, which is the value under consideration. The callback signature is `function(err, bins, metadata, key)`

err - err.code == AEROSPIKE\_OK, signifies the success/failure of the operate call. bins - If there is a read operation specified in the operation array, an example `op.read('bin1')` then the updated value of bin1 is returned. If there’s no read operation specified, then no bins will be retrieved.

metadata - contains ttl and generation of the record. Returned when there is atleast one read operation. key: Key of the record, returned always.

Hope this extra information helps. But if you can give us more details about which callback value we are talking about, that would be great.

---

<div class="post-metadata">

**Author:** ![VikramTiwari](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/vikramtiwari/32/97_2.png) [@VikramTiwari](https://discuss.aerospike.com/u/VikramTiwari)\
**Post date:** [December 2, 2014, 1:09pm UTC](https://discuss.aerospike.com/t/create-vs-update-operations/560/3 "2014-12-02T13:09:48Z")

</div>

Hi Gayathri,

The issue that i am facing is that neither the err, bin value or metadata returned is different for the cases of a new value insert vs update.

---

<div class="post-metadata">

**Author:** ![gayathri](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@gayathri](https://discuss.aerospike.com/u/gayathri)\
**Post date:** [December 2, 2014, 4:36pm UTC](https://discuss.aerospike.com/t/create-vs-update-operations/560/4 "2014-12-02T16:36:48Z")

</div>

Hi Vikram,

We do not have a way differentiate between an update and new write in operate function call. But we have a work around for this. You can specify a read operation of the bin you are operating on. If your application logic can differentiate between update and a write, reading the bin that’s operated on would be a solution.

---

<div class="post-metadata">

**Author:** ![VikramTiwari](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/vikramtiwari/32/97_2.png) [@VikramTiwari](https://discuss.aerospike.com/u/VikramTiwari)\
**Post date:** [December 2, 2014, 6:33pm UTC](https://discuss.aerospike.com/t/create-vs-update-operations/560/5 "2014-12-02T18:33:09Z")

</div>

Is there no other way? For now i have handled it in application logic itself, but a better callback is preferable.

Thanks for the clarification 😄

---

<div class="post-metadata">

**Author:** ![gayathri](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@gayathri](https://discuss.aerospike.com/u/gayathri)\
**Post date:** [April 30, 2015, 9:01am UTC](https://discuss.aerospike.com/t/create-vs-update-operations/560/6 "2015-04-30T09:01:42Z")

</div>

Hi Vikram,

We don’t have any other way 🙂
