alwint3r / sequelize-datatable-node

MIT License
11 stars 12 forks source link

Does not work search #2

Closed ghost closed 7 years ago

ghost commented 7 years ago

When attempting any search, the server does not return anything

Query params (GET)

draw:5 columns[0][data]:0 columns[0][name]: columns[0][searchable]:true columns[0][orderable]:false columns[0][search][value]: columns[0][search][regex]:false columns[1][data]:1 columns[1][name]: columns[1][searchable]:true columns[1][orderable]:false columns[1][search][value]: columns[1][search][regex]:false columns[2][data]:2 columns[2][name]: columns[2][searchable]:true columns[2][orderable]:false columns[2][search][value]: columns[2][search][regex]:false columns[3][data]:3 columns[3][name]: columns[3][searchable]:true columns[3][orderable]:false columns[3][search][value]: columns[3][search][regex]:false columns[4][data]:4 columns[4][name]: columns[4][searchable]:true columns[4][orderable]:false columns[4][search][value]: columns[4][search][regex]:false columns[5][data]:5 columns[5][name]: columns[5][searchable]:true columns[5][orderable]:false columns[5][search][value]: columns[5][search][regex]:false columns[6][data]:6 columns[6][name]: columns[6][searchable]:true columns[6][orderable]:false columns[6][search][value]: columns[6][search][regex]:false columns[7][data]:7 columns[7][name]: columns[7][searchable]:true columns[7][orderable]:false columns[7][search][value]: columns[7][search][regex]:false columns[8][data]:8 columns[8][name]: columns[8][searchable]:true columns[8][orderable]:false columns[8][search][value]: columns[8][search][regex]:false columns[9][data]:9 columns[9][name]: columns[9][searchable]:true columns[9][orderable]:false columns[9][search][value]: columns[9][search][regex]:false start:0 length:10 search[value]:Алек search[regex]:false _:1508587158062

Response {"draw":5,"data":[],"recordsFiltered":0,"recordsTotal":5,"_":"1508587158062"}

Server logging Executing (default): DESCRIBE users; Executing (default): SELECT count() AS count FROM users AS users; Executing (default): SELECT count() AS count FROM users AS users WHERE 0 = 1; Executing (default): SELECT id, identity, name, avatar, sex, privilege, balance, referral, referral_code, created_at, updated_at FROM users AS users WHERE 0 = 1 LIMIT 0, 10;

Table screen http://prntscr.com/h051fs

Server code

router.get('/', async (req, res) => { res.json(await dataTables(models.users, req.query, {})); });

Model

const users = sequelize.define('users', { identity: dataTypes.TEXT, name: dataTypes.TEXT, avatar: dataTypes.TEXT, sex: dataTypes.INTEGER, privilege: dataTypes.INTEGER, balance: dataTypes.INTEGER, referral: dataTypes.TEXT, referral_code: dataTypes.TEXT, created_at: { type: dataTypes.DATEONLY, get: function () { return moment.utc(this.getDataValue('created_at')).format('D MMM YYYY, HH:mm'); } }, updated_at: { type: dataTypes.DATEONLY, get: function () { return moment.utc(this.getDataValue('updated_at')).format('D MMM YYYY, HH:mm'); } } });

xeleniumz commented 7 years ago

Hi @n-lebedev I think you should recheck your code again. Data will resprent in json format in variable because I've used this lib too and it's working fine.