lib/doormen-extensions.js
function toLink( data ) {
	if ( data && typeof data === 'object' ) {
		if ( data.constructor.name === 'ObjectID' || data.constructor.name === 'ObjectId' ) {
			return { _id: data } ;
		}

		data._id = toObjectId( data._id ) ;
	}
	else if ( typeof data === 'string' ) {
		try {
			data = { _id: mongodb.ObjectID( data ) } ;
		}
		catch ( error ) {}
	}

	return data ;
}
function toLink( data ) {
	if ( data && typeof data === 'object' ) {
		if ( data.constructor.name === 'ObjectID' || data.constructor.name === 'ObjectId' ) {
			return { _id: data } ;
		}

		data._id = toObjectId( data._id ) ;
	}
	else if ( typeof data === 'string' ) {
		try {
			data = { _id: mongodb.ObjectID( data ) } ;
		}
		catch ( error ) {}
	}

	return data ;
}
function toLink ( data ) { if ( data && typeof data === 'object' ) { if ( data . constructor . name === 'ObjectID' || data . constructor . name === 'ObjectId' ) { return { _id : data } ; } data . _id = toObjectId ( data . _id ) ; } else if ( typeof data === 'string' ) { try { data = { _id : mongodb . ObjectID ( data ) } ; } catch ( error ) { } } return data ; }
Allow one to pass the whole linked target object
Allow one to pass the whole linked target object