1

I'm using RavenDB 2.5. I want to update a single field on all documents in a specific collection. I want each document to have a unique value in this field. I am currently attempting this via 'patching' from the web portal, but I will gladly do it another way if that is needed.

Here is what I tried in the patch request in the web portal.

var i = 1000;
this.UniqueField = i++;

Obviously, this doesn't work. Every field gets a value of 1000. I don't know what else to try though.

Secondarily, I would prefer the unique values to be a Guid (cast to a string) instead of an integer. However, I will take whatever I can get as long as the fields are unique.

user1304444
  • 1,713
  • 3
  • 21
  • 38

1 Answers1

0

You can use Jscript to define a guid and then assign a new one to each field:

Suppose you wanted to setUniqueField on each User object (remember to Patch Collection)

enter image description here

Guid code taken from here

Community
  • 1
  • 1
wal
  • 17,409
  • 8
  • 74
  • 109