Using UUID() method for key generation


We are planning on using a UUID to use as a key for our documents. I was wondering if there is a recommended way to do it. From what I could find the only way ( at least on the couchbase side ) seems to generate a random UUID using the UUID() function. Is this a reasonable way to go about it or are there some better alternatives?


Hi @silver.soul,

The UUID() function would work fine if you’re creating your documents via N1QL. If you’re creating documents via SDK, then you would need to generate a UUID in the client. For instance, with C#:

var document = new Document<MyDocument>
		Id = Guid.NewGuid().ToString(),
		Content = new MyDocument
			Name = "Silver Soul"


I see, I’ll go with the n1ql way then. Thanks @matthew.groves