レコードを見つける
検索するには、
私たちのFindingRankテスト.jsファイル
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();
})
})
})
Reference
この問題について(レコードを見つける), 我々は、より多くの情報をここで見つけました https://dev.to/rittwickbhabak/8-finding-records-3jjmテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol