レコードを見つける


検索するには、findまたはfindOneメソッドをモデルに使用できます.
MarioChar.findOne({ name: "Mario"}).then(result => {
    ...
})
このコードは、最初のマッチを見つけます.
私たちのFindingRankテスト.jsファイル
const assert = require('assert');
const MarioChar = require('../models/mariochar');

describe('Some demo tests', function(){

    beforeEach(function(done){
        var character = new MarioChar({
            name: "Mario",
        })
        character.save().then(function(){
            assert(character.isNew === false)
            done();
        })
    })

    //Create tests
    it('Finding a record form the database', function(done){
        MarioChar.findOne({ name: "Mario"}).then(result => {
            assert(result.name === "Mario")
            done();
        })
    })
})