Gravity
Search…
Database Queries
Before making a database query in your application, you must import the database model into the file where your methods are contained.
1
// sql
2
const db = require('./knex')();
3
4
// mongo
5
const mongoose = require('mongoose');
Copied!

Performing Database Queries

You can perform a query using Knex or Mongoose.
1
// knex
2
return await db('user').select('*').where({ account_id: account });
3
4
// mongoose
5
return await User.findOne({ account_id: account });
Copied!
Last modified 1yr ago