Get most recent document name or ID

Hello,

Is there a command in PHP/Couchbase that would return a similar result as:
select Max(*) id from table? Basically I want my application to get the name of the last document in a bucket that was created so I can increment. I am using numbers as the name basically using it as the ID.

Thank you!

Hey rmazin,

We do not directly support the ability to do this with Couchbase Server. However, you can create a single document that can act as your counter, containing just the current document number to use, then perform a counter operation on it to increment it and return the value, allowing you to create documents with incrementing identifiers.

Cheers, Brett

Thanks Brett, I will give that a try.

Randy