<commit_before>var Promise = require('bluebird');
var util = require('util');
var Schema = require('./schema');
var NotFoundError = require('./errors/NotFoundError');

var Model = function(schema) {
	if (!schema) {
		throw new Error('Cannot create model without schema');
	}
	this.schema = new Schema(schema);
};

Model.prototype.get = function(pk, store) {
	console.log(pk);
	return new Promise(function(resolve, reject) {
		store.getEntry(pk).then(function(obj) {
			if (!obj) {
				return reject(new NotFoundError(util.format('Instance with pk %s is not found', pk)));
			}
			resolve(obj);
		}).catch(function(err) {
			reject(err);
		});
	});
};

Model.prototype.set = function(obj, operation, store) {
	obj = obj || {};
	var that = this;
	return new Promise(function(resolve, reject) {
		that.schema.create(obj).then(function(instance) {
			this.instance = instance;
			return store.setEntry(instance, operation);
		}).then(function() {
			resolve(this.instance);
		}).catch(function(err) {
			reject(err);
		});
	});
};

Model.prototype.delete = function(pk, store) {		
	return store.deleteEntry(pk);
};
<commit_msg>chore(npm) Version bump<commit_after>var Promise = require('bluebird');
var util = require('util');
var Schema = require('./schema');
var NotFoundError = require('./errors/NotFoundError');

var Model = function(schema) {
	if (!schema) {
		throw new Error('Cannot create model without schema');
	}
	this.schema = new Schema(schema);
};

Model.prototype.get = function(pk, store) {
	return new Promise(function(resolve, reject) {
		store.getEntry(pk).then(function(obj) {
			if (!obj) {
				return reject(new NotFoundError(util.format('Instance with pk %s is not found', pk)));
			}
			resolve(obj);
		}).catch(function(err) {
			reject(err);
		});
	});
};

Model.prototype.set = function(obj, operation, store) {
	obj = obj || {};
	var that = this;
	return new Promise(function(resolve, reject) {
		that.schema.create(obj).then(function(instance) {
			this.instance = instance;
			return store.setEntry(instance, operation);
		}).then(function() {
			resolve(this.instance);
		}).catch(function(err) {
			reject(err);
		});
	});
};

Model.prototype.delete = function(pk, store) {		
	return store.deleteEntry(pk);
};

{'fraction_non_alphanumeric': 0.17336907953529937, 'fraction_numerical': 0.0, 'mean_word_length': 4.514778325123153, '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': '4956900', 'n_tokens_mistral': 774, 'n_tokens_neox': 716, 'n_words': 159}