I am using Ottoman to interact with Couch base in my application for Curd operations.
I have an document model like
User:{
username:‘string’,
_id:{type:‘string’, auto:‘uuid’, readonly:true},
phone:[{
phone_id:{type:‘string’, auto:‘uuid’, readonly:true},
phone_number:‘string’,
phone_type:‘string’
}]
}
When i try to create a document with this model Ottoman generates a UUID for the _id field but is not generating one for the internal phone_id field.
Two things I need inputs for.
How can I generate an Id for this field.
I will be deploying my node application on a cluster will this UUID remain unique around all instances on the cluster or there is a chance of two applications generating similar UUID for two insert request in exponentially heavy load scenario?
Hi,
1./ I’ve looked a bit into the source , I think ottoman currently does not support default value/ auto UUID generation for nested object
2./ UUID generation process is kind of guarantee to be unique every time it generated a new one . you can read more about this here
[https://en.wikipedia.org/wiki/Universally_unique_identifier]
What I’m talking about is default value for nested object . Check this test case .
it('uid created for nested object', function() {
var Something = ottoman.model('Something', {
uid: {type: 'string', default: uuid.v4()},
nestedObj:{
uid:{type: 'string', default: uuid.v4()},
}
});
var p = new Something();
assert.ok('uid' in p); //ok
assert.ok('uid' in p.nestedObj); //failed
});