server/src/bl/thingsMngr.js
function getThingPosition(user, parentThing, childThing) {

	if (!childThing)
		throw new utils.ErrorCustom(httpStatusCodes.INTERNAL_SERVER_ERROR, "Child Thing can't be null", 29);

	// If User is equal to null as it may be anonymous or is a SuperAdministrator who has no relationship with Thing
	if (!user)
		return null;

	let userId = user._id;
	let parentThingId = parentThing ? parentThing._id : null;

	return childThing.parentsThingsIds.find(p => p.userId == userId && p.parentThingId == parentThingId);
}
function getThingPosition(user, parentThing, childThing) {

	if (!childThing)
		throw new utils.ErrorCustom(httpStatusCodes.INTERNAL_SERVER_ERROR, "Child Thing can't be null", 29);

	// If User is equal to null as it may be anonymous or is a SuperAdministrator who has no relationship with Thing
	if (!user)
		return null;

	let userId = user._id;
	let parentThingId = parentThing ? parentThing._id : null;

	return childThing.parentsThingsIds.find(p => p.userId == userId && p.parentThingId == parentThingId);
}
function getThingPosition ( user , parentThing , childThing ) { if ( ! childThing ) throw new utils . ErrorCustom ( httpStatusCodes . INTERNAL_SERVER_ERROR , "Child Thing can't be null" , 29 ) ; // If User is equal to null as it may be anonymous or is a SuperAdministrator who has no relationship with Thing if ( ! user ) return null ; let userId = user . _id ; let parentThingId = parentThing ? parentThing . _id : null ; return childThing . parentsThingsIds . find ( p => p . userId == userId && p . parentThingId == parentThingId ) ; }
User may be null as it may be anonymous or is a SuperAdministrator who has no relationship with Thing It may return null for old Thing created before Position Management
User may be null as it may be anonymous or is a SuperAdministrator who has no relationship with Thing It may return null for old Thing created before Position Management