<commit_before>'use strict'
var mongoose = require("mongoose");
var co = require("co");
var Schema = mongoose.Schema,
    ObjectId = Schema.ObjectId;
var should = require("should");


var mixedSchema = new Schema({
    data: {type: Schema.Types.Mixed}
});

describe("Schema_Mixed", function () {
    mongoose.connect('mongodb://localhost/test');
    var Mixed = mongoose.model('mixed', mixedSchema);
    before(function (done) {
        co(function* () {
            yield Mixed.remove({});
            done();
        })
    })

    it("create", function (done) {
        co(function* () {
            var mixed = new Mixed();
            mixed.data = {name: "JIE"}
            mixed.markModified("data")
            yield mixed.save();
            mixed = yield Mixed.findOne({"data.name": "JIE"});
            mixed.data.should.have.property("name", "JIE");
            done();
        })
            .catch(function (err) {
                console.log(err)
            });
    })

    it("remove", function (done) {
        co(function* () {
            try {
                var mixed = new Mixed();
                mixed.data = {name: "JIE"}
                mixed.markModified("data")
                yield mixed.save();
                yield Mixed.remove({"data.name": "JIE"});
                mixed = yield Mixed.findOne({"data.name": "JIE"});
                (mixed === null).should.be.true;
                done();
            } catch (err) {
                console.log(err);
            }
        });
    })


    it("update", function (done) {
        co(function* () {
            try {
                var mixed = new Mixed();
                mixed.data = {name: "JIE"};
                //mixed.markModified("data"); // 不需要了，也可以正常保存数据
                yield mixed.save();
                mixed = yield Mixed.findOne({"data.name": "JIE"});
                mixed.data = {"gender": 1};<commit_msg>添加 mixed 定义为String 测试<commit_after>'use strict'
var mongoose = require("mongoose");
var co = require("co");
var Schema = mongoose.Schema,
    ObjectId = Schema.ObjectId;
var should = require("should");


var mixedSchema = new Schema({
    data: {type: Schema.Types.Mixed}
});

describe("Schema_Mixed", function () {
    mongoose.connect('mongodb://localhost/test');
    var Mixed = mongoose.model('mixed', mixedSchema);
    before(function (done) {
        co(function* () {
            yield Mixed.remove({});
            done();
        })
    })

    it("create Object", function (done) {
        co(function* () {
            var mixed = new Mixed();
            mixed.data = {name: "JIE"}
            yield mixed.save();
            mixed = yield Mixed.findOne({"data.name": "JIE"});
            mixed.data.should.have.property("name", "JIE");
            done();
        })
            .catch(function (err) {
                console.log(err)
            });
    })


    it("create String", function (done) {
        co(function* () {
            var mixed = new Mixed();
            mixed.data = "test"
            yield mixed.save();
            mixed = yield Mixed.findOne({"data": "test"});
            mixed.should.have.property("data", "test");
            done();
        })
            .catch(function (err) {
                console.log(err)
            });
    })


    it("remove", function (done) {
        co(function* () {
            try {
                var mixed = new Mixed();
                mixed.data = {name: "JIE"}
                mixed.markModified("data")
                yield mixed.save();
                yield Mixed.remove({"data.name": "JIE"});
                mixed = yield Mixed.findOne({"data.name": "JIE"});
                (mixed === null).should.be.true;
                done();
            } catch (err) {
                console.log(err);
            }
        });
    })


    it("update", function (done) {
        co(function* () {
            try {
                var mixed = new Mixed();
                mixed.data = {name: "JIE"};
                //mixed.markModified("data"); // 不需要了，也可以正常保存数据
                yield mixed.save();
                mixed = yield Mixed.findOne({"data.name": "JIE"});
                mixed.data = {"gender": 1};
{'fraction_non_alphanumeric': 0.16087577344121848, 'fraction_numerical': 0.00047596382674916705, 'mean_word_length': 1.5395770392749244, 'pattern_counts': {'":': 11, '<': 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': '2589962', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1166, 'n_words': 247}