<commit_before>module.exports = {
	attributes: {
		title: {
			type: 'string',
			required: true
		},
		user: {
			model: 'user'
		}
	},

	/**
	* Callback to be run after creating a Message.
	*
	* @param {Object}   message The soon-to-be-created Message
	* @param {Function} next
	*/
	afterCreate: function (message, next) {
		// set message.user = to appropriate user model
		User.getOne(message.user)
		.spread(function(user) {
			message.user = user;
			next(null, message);
		});
	},

	getAll: function() {
		return Message.find()
		// TODO: sort by createdAt DESC does not work here, something to do with a camelCase key names bug
		.sort({id: 'desc'})
		.populate('user')
		.then(function (models) {
			return [models];
		});
	},

	getOne: function(id) {
		return Message.findOne(id)<commit_msg>sort by createdAt desc so newest messages appear at the top<commit_after>module.exports = {
	attributes: {
		title: {
			type: 'string',
			required: true
		},
		user: {
			model: 'user'
		}
	},

	/**
	* Callback to be run after creating a Message.
	*
	* @param {Object}   message The soon-to-be-created Message
	* @param {Function} next
	*/
	afterCreate: function (message, next) {
		// set message.user = to appropriate user model
		User.getOne(message.user)
		.spread(function(user) {
			message.user = user;
			next(null, message);
		});
	},

	getAll: function() {
		return Message.find()
		// TODO: sort by createdAt DESC does not work here, something to do with a camelCase key names bug
		.sort({createdAt: 'desc'})
		.populate('user')
		.then(function (models) {
			return [models];
		});
	},

	getOne: function(id) {
		return Message.findOne(id)
{'fraction_non_alphanumeric': 0.14259818731117824, 'fraction_numerical': 0.0, 'mean_word_length': 3.2570694087403598, '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': '2602386', 'n_tokens_mistral': 627, 'n_tokens_neox': 561, 'n_words': 161}