> For the complete documentation index, see [llms.txt](https://docs.usegravity.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.usegravity.app/gravity-server/database-queries.md).

# Database Queries

Before executing a database query, you must import the database model into the file where you will perform the query (usually your model file).

```javascript
// sql
const db = require('./knex')();

// mongo
const mongoose = require('mongoose');
```

### Performing Database Queries&#x20;

You can perform a query using [Knex](https://knexjs.org) or [Mongoose](https://mongoosejs.com).

```javascript
// knex
return await db('user').select('*').where({ account_id: account });

// mongoose
return await User.findOne({ account_id: account });
```
