<commit_before>var Constants = require('../../../../common_classes/Constants');
var Common = require('../../../../common_classes/Common')
var Path = require('../../../../common_classes/Path');
var logger = require('tracer').console();
var FieldVal = require('fieldval');
var BasicVal = FieldVal.BasicVal;
var validators = require('../../validators');

function DeleteObject(address, handler, index, options){
	var del_obj = this;

	var address_details = Common.get_resource_type(address);
    logger.log("address_details ",address_details);
    var address_type = address_details[0];
    var address_value = address_details[1];

    if(address_type==="path"){
    	del_obj.path = address_value;
    	del_obj.address_type = DeleteObject.BY_PATH;
    } else if(address_type==="id"){
        del_obj.id = address_value;
        del_obj.address_type = DeleteObject.BY_ID;
    } else {
        logger.log("DeleteObject address_type ",address_type);
        del_obj.error = FieldVal.Error(0)
    }

	del_obj.options = options || {};
	del_obj.handler = handler;
	del_obj.index = index;
}

DeleteObject.BY_ID = 0;
DeleteObject.BY_PATH = 1;

DeleteObject.prototype.do_deleting = function(on_delete_callback){
	var del_obj = this;

	var db = del_obj.handler.api.ds;

	if(del_obj.error){//Already have an error
		on_delete_callback(del_obj.error);
		return;
	}


	var find_query;

	if(del_obj.address_type===DeleteObject.BY_ID){
		find_query = {
			_id: del_obj.id
		};
	} else {//Is by address
		logger.log(del_obj.path);
		find_query = {
			full_path: del_obj.path.toString()
		};
	}

	logger.log(find_query);


	db.object_collection.findOne(
    	find_query,function(err,res){
<commit_msg>Fixed DeleteObject error callback<commit_after>var Constants = require('../../../../common_classes/Constants');
var Common = require('../../../../common_classes/Common')
var Path = require('../../../../common_classes/Path');
var logger = require('tracer').console();
var FieldVal = require('fieldval');
var BasicVal = FieldVal.BasicVal;
var validators = require('../../validators');

function DeleteObject(address, handler, index, options){
	var del_obj = this;

	var address_details = Common.get_resource_type(address);
    logger.log("address_details ",address_details);
    var address_type = address_details[0];
    var address_value = address_details[1];

    if(address_type==="path"){
    	del_obj.path = address_value;
    	del_obj.address_type = DeleteObject.BY_PATH;
    } else if(address_type==="id"){
        del_obj.id = address_value;
        del_obj.address_type = DeleteObject.BY_ID;
    } else {
        logger.log("DeleteObject address_type ",address_type);
        del_obj.error = FieldVal.Error(0)
    }

	del_obj.options = options || {};
	del_obj.handler = handler;
	del_obj.index = index;
}

DeleteObject.BY_ID = 0;
DeleteObject.BY_PATH = 1;

DeleteObject.prototype.do_deleting = function(on_delete_callback){
	var del_obj = this;

	var db = del_obj.handler.api.ds;

	if(del_obj.error){//Already have an error
		on_delete_callback(del_obj, del_obj.error);
		return;
	}


	var find_query;

	if(del_obj.address_type===DeleteObject.BY_ID){
		find_query = {
			_id: del_obj.id
		};
	} else {//Is by address
		logger.log(del_obj.path);
		find_query = {
			full_path: del_obj.path.toString()
		};
	}

	logger.log(find_query);


	db.object_collection.findOne(
    	find_query,function(err,res){

{'fraction_non_alphanumeric': 0.1501032143910351, 'fraction_numerical': 0.002948982601002654, 'mean_word_length': 3.866571018651363, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5557126', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1128, 'n_words': 200}