<commit_before>var Q = require('q');
var mongoose = require('mongoose');

/**
 * Connect to MongoDB Database.
 *
 * @param {String} db
 */

exports.connect = function(db) {
    if (!db) db = 'mongodb://localhost:27017/ps';
    var url = process.env.MONGODB || db;
    mongoose.connect(url);
    mongoose.connection.on('error', function() {
        console.error('MongoDB Connection Error. Make sure MongoDB is running.');
    });
};

var userSchema = new mongoose.Schema({
    name: { type: String, lowercase: true, unique: true },
    money: { type: Number, default: 0 },
    symbol: String,
    seen: Date,
    cards: Array
});

var User = exports.userModel = mongoose.model('user', userSchema);

exports.User = {
    /**
     * Promise wrapper for User.findOne.
     * 
     * @param {Object} query
     * @return {Promise}
     */
    findOne: function(query) {
        var deferred = Q.defer();
        User.findOne(query, function(err, result) {
            if (err) return deferred.reject(new Error(err));
            deferred.resolve(result);
        });
        return deferred.promise;
    },
    /**
     * Promise wrapper for User.find.
     * 
     * @param {Object} query
     * @return {Promise}
     */
    find: function(query) {
        var deferred = Q.defer();
        User.find(query, function(err, result) {
            if (err) return deferred.reject(new Error(err));
            deferred.resolve(result);<commit_msg>Add marketplace schema<commit_after>var Q = require('q');
var mongoose = require('mongoose');

/**
 * Connect to MongoDB Database.
 *
 * @param {String} db
 */

exports.connect = function(db) {
    if (!db) db = 'mongodb://localhost:27017/ps';
    var url = process.env.MONGODB || db;
    mongoose.connect(url);
    mongoose.connection.on('error', function() {
        console.error('MongoDB Connection Error. Make sure MongoDB is running.');
    });
};

var userSchema = new mongoose.Schema({
    name: { type: String, lowercase: true, unique: true },
    money: { type: Number, default: 0 },
    symbol: String,
    seen: Date,
    cards: Array
});

var User = exports.userModel = mongoose.model('user', userSchema);

var marketplaceSchema = new mongoose.Schema({
    cid: { type: String, unique: true},
    card: String,
    name: String,
    rarity: String,
    points: Number,
    owner: String,
    price: Number
});

export.MarketPlace = mongoose.model('marketplace', marketplaceSchema);

exports.User = {
    /**
     * Promise wrapper for User.findOne.
     * 
     * @param {Object} query
     * @return {Promise}
     */
    findOne: function(query) {
        var deferred = Q.defer();
        User.findOne(query, function(err, result) {
            if (err) return deferred.reject(new Error(err));
            deferred.resolve(result);
        });
        return deferred.promise;
    },
    /**
     * Promise wrapper for User.find.
     * 
     * @param {Object} query
     * @return {Promise}
     */
    find: function(query) {
        var deferred = Q.defer();
        User.find(query, function(err, result) {
            if (err) return deferred.reject(new Error(err));
            deferred.resolve(result);
{'fraction_non_alphanumeric': 0.14597156398104266, 'fraction_numerical': 0.0037914691943127963, 'mean_word_length': 2.5413870246085013, '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': '2529736', 'n_tokens_mistral': 987, 'n_tokens_neox': 970, 'n_words': 245}