Database Queries

Before making a database query in your application, you must import the database model into the file where your methods are contained.

// sql
const db = require('./knex')();
// mongo
const mongoose = require('mongoose');

Performing Database Queries

You can perform a query using Knex or Mongoose.

// knex
return await db('user').select('*').where({ account_id: account });
// mongoose
return await User.findOne({ account_id: account });