“Sekuat FindOne” Kode Jawaban

Sequellize Temukan satu

const project = await Project.findOne({ where: { title: 'My Title' } });
if (project === null) {
  console.log('Not found!');
} else {
  console.log(project instanceof Project); // true
  console.log(project.title); // 'My Title'
}
Ham-Solo

Sekuat Get Where

// Example
const Tokens = db.define('tokens', {
    guid: {
        type: sequelize.STRING
    }
});
// The basics of Sequelize Get Where
Tokens.findAll({
        where: { guid: 'guid12345' }
    }).then(tokens => {
        console.log(tokens);
    }).catch(err => console.log('error: ' + err));;
// is equal to >> SELECT * FROM Tokens WHERE guid = 'guid12345'
Ham-Solo

Sekuat Maks

  exports.getMinPrice = () => Item.findAll({    attributes: [[sequelize.fn('min', sequelize.col('price')), 'minPrice']],  });
johannb75

Sekuat FindOne

const project = await Project.findOne({ where: { title: 'My Title' } });
if (project === null) {
  console.log('Not found!');
} else {
  console.log(project instanceof Project); // true
  console.log(project.title); // 'My Title'
}
saad ali

Jawaban yang mirip dengan “Sekuat FindOne”

Pertanyaan yang mirip dengan “Sekuat FindOne”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya