Rich document ids for CouchDB
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Go to file
Johannes J. Schmidt 461c7ee0db change sequence of version and index
Before this api breaking change a docuri looked like this:
`type/id/subtype/version/index`
Now we swapped version and index:
`type/id/subtype/index/version`
10 years ago
test change sequence of version and index 10 years ago
.gitignore first commit 10 years ago
.travis.yml test on current versions 10 years ago
README.md change sequence of version and index 10 years ago
index.js change sequence of version and index 10 years ago
package.json change sequence of version and index 10 years ago

README.md

docuri Build Status

Rich document ids for CouchDB.

type/id/subtype/index/version

eg movie/blade-runner/gallery-image/12/medium

Usage

Parse id string:

require('docuri').parse('mytype/myid/mysubtype/myindex/myversion');
// {
//   type: 'mytype',
//   id: 'myid',
//   subtype: 'mysubtype',
//   index: 'myindex',
//   version: 'myversion'
// }

Build id string from object:

require('docuri').stringify({
  type: 'mytype',
  id: 'myid',
  subtype: 'mysubtype',
  index: 'myindex',
  version: 'myversion'
});
// 'mytype/myid/mysubtype/myindex/myversion'

Change id string components:

require('docuri').merge('mytype/myid/mysubtype/myindex/myversion', {
  type: 'my_new_type',
});
// 'my_new_type/myid/mysubtype/myindex/myversion'

Browser support

To use docid in your client-side application, browserify it like this:

browserify -s DocURI path/to/docuri/index.js > path/to/your/assets

Once added to your DOM, this will leave you with a global DocURI object for use in your e.g. Backbone Models/Collections.

Development

To run the unit tests:

npm test

For JShint:

npm run jshint

License

Copyright (c) 2014 Johannes J. Schmidt, null2 GmbH
Licensed under the MIT license.