sequely
v1.0.1
Published
Introducing Sequelize Query Builder for Node.js, a powerful tool to help you simplify and optimize your database queries. With this tool, you can quickly and easily craft complex queries and access data in your database. You'll be able to get the most out
Downloads
3
Maintainers
Readme
sequely
Backend
const { sq } = require("sequely");
const { Users, Posts } = require("../models");
async function getUsersList(req, res){
try{
let users = await sq(Users, req, (options)=>{
options.include = { model: Posts, required: false }
});
res.status(200).send(users);
}catch(e){
res.status(500).send(e.message);
}
}
Frontend
import axios from "axios";
async function getUsersList(){
try{
let query = JSON.stringify({
filter: { name: "Don" },
filter_in: { id: [ 1, 2, 3 ] },
filter_notin: { id: [ 1, 2, 3 ] },
search: { name: "do", email: "do" },
sort: ["id", "DESC"],
between: { age: { from: 10, to: 20 } },
pagination: true, // default true
page: 2, // working when pagination is true
limit: 10, // working when pagination is true , default value 10
});
let users = await axios.get("http://domain.com/users", { params: { query } });
console.log(users);
}catch(e){
console.log(e.message);
}
}