<commit_before>'use strict'

const mongoose = require('mongoose')
const { getSchema } = require('./schemas')
const config = require('config')

// Use native promises with Mongoose
mongoose.Promise = Promise


module.exports = {
	People:       model('People'),
	Activity:     model('Activity'),
	Organization: model('Organization'),
	connect
}


function model (name) {
	const desc = getSchema(name)
	const schema = new mongoose.Schema(desc)
	return mongoose.model(name, schema)
}

function connect (url = null) {
	return new Promise((resolve, reject) => {
		mongoose.connect(url || config.mongo.url, e => e ? reject(e) : resolve(mongoose.connection))
	})
}<commit_msg>feat(model): throws when trying to save a document with unknown fields added<commit_after>'use strict'

const mongoose = require('mongoose')
const { getSchema } = require('./schemas')
const config = require('config')

// Use native promises with Mongoose
mongoose.Promise = Promise


module.exports = {
	People:       model('People'),
	Activity:     model('Activity'),
	Organization: model('Organization'),
	connect
}


function model (name) {
	const desc = getSchema(name)
	const schema = new mongoose.Schema(desc, {
		strict: 'throw'
	})
	return mongoose.model(name, schema)
}

function connect (url = null) {
	return new Promise((resolve, reject) => {
		mongoose.connect(url || config.mongo.url, e => e ? reject(e) : resolve(mongoose.connection))
	})
}
{'fraction_non_alphanumeric': 0.14125087842586087, 'fraction_numerical': 0.0, 'mean_word_length': 4.673306772908367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '615394', 'n_tokens_mistral': 437, 'n_tokens_neox': 440, 'n_words': 119}