<commit_before>var mongoose = require('mongoose');
var sugar = require('../lib/mongoose-sugar');

var schema = sugar.schema(mongoose);
var ref = sugar.ref;
var refs = sugar.refs;
var unique = sugar.unique;

exports.Author = schema('Author', {
    name: {type: String, required: true},
    nick: String,
    extra: mongoose.Schema.Types.Mixed
});

exports.License = schema('License', {
    name: {type: String, unique: true}
});

exports.Library = schema('Library', {
    author: ref('Author', {required: true}),
    name: {type: String, required: true},
    licenses: refs('License')
});
<commit_msg>Define LibraryAuthor schema for testing<commit_after>var mongoose = require('mongoose');
var sugar = require('../lib/mongoose-sugar');

var schema = sugar.schema(mongoose);
var ref = sugar.ref;
var refs = sugar.refs;
var unique = sugar.unique;

exports.Author = schema('Author', {
    name: {type: String, required: true},
    nick: String,
    extra: mongoose.Schema.Types.Mixed
});

exports.License = schema('License', {
    name: {type: String, unique: true}
});

exports.Library = schema('Library', {
    author: ref('Author', {required: true}),
    name: {type: String, required: true},
    licenses: refs('License')
});

// this a bit contrived example illustrates how to use
// schemas as sort of templates. this schema is needed
// for testing delete cascade as well
exports.LibraryAuthor = schema('LicenseAuthor', {
    library: ref('Library', {required: true}),
    author: ref('Author', {required: true}),
    role: String
});
{'fraction_non_alphanumeric': 0.16135328562134027, 'fraction_numerical': 0.0, 'mean_word_length': 4.321799307958478, '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': '5474860', 'n_tokens_mistral': 468, 'n_tokens_neox': 471, 'n_words': 138}