lib/main.js
function(label, property_key, callback) {
	var that = this;
	var val = new Validator();
	val.label(label).property(property_key);

	if (val.hasErrors) {
		return callback(val.error(), null);
	}

	request
		.post(that.url + '/db/data/schema/constraint/' + label + '/uniqueness')
		.set(this.header)
		.send({ 'property_keys' : [property_key] })
		.end(function(result) {
			switch(result.statusCode) {
				case 200:
					callback(null, result.body);
					break;
				case 409:
					callback(null, false); // Constraint already exists
					break;
				default:
					callback(new Error('HTTP Error ' + result.statusCode + ' when creating a uniqueness contraint.'), null);
			}
		});
}
function(label, property_key, callback) {
	var that = this;
	var val = new Validator();
	val.label(label).property(property_key);

	if (val.hasErrors) {
		return callback(val.error(), null);
	}

	request
		.post(that.url + '/db/data/schema/constraint/' + label + '/uniqueness')
		.set(this.header)
		.send({ 'property_keys' : [property_key] })
		.end(function(result) {
			switch(result.statusCode) {
				case 200:
					callback(null, result.body);
					break;
				case 409:
					callback(null, false); // Constraint already exists
					break;
				default:
					callback(new Error('HTTP Error ' + result.statusCode + ' when creating a uniqueness contraint.'), null);
			}
		});
}
function ( label , property_key , callback ) { var that = this ; var val = new Validator ( ) ; val . label ( label ) . property ( property_key ) ; if ( val . hasErrors ) { return callback ( val . error ( ) , null ) ; } request . post ( that . url + '/db/data/schema/constraint/' + label + '/uniqueness' ) . set ( this . header ) . send ( { 'property_keys' : [ property_key ] } ) . end ( function ( result ) { switch ( result . statusCode ) { case 200 : callback ( null , result . body ) ; break ; case 409 : callback ( null , false ) ; // Constraint already exists break ; default : callback ( new Error ( 'HTTP Error ' + result . statusCode + ' when creating a uniqueness contraint.' ) , null ) ; } } ) ; }
/* CONSTRAINTS /*	Create a uniqueness constraint on a property.
Example:
createUniquenessConstraint('User','email', callback);
returns 	{
'label' : 'User',
'type' : 'UNIQUENESS',
'property-keys' : [ 'email' ]
}
/ * CONSTRAINTS / * Create a uniqueness constraint on a property . Example : createUniquenessConstraint ( User email callback ) ; returns { label : User type : UNIQUENESS property - keys : [ email ] }