website
website copied to clipboard
docs: fix incorrect example of attributes in SELECT query docs
Under the heading "Specifying attributes for SELECT queries" in the "Model Querying - Basics" documentation page, the example incorrectly used:
Model.findAll({
attributes: ['foo', ['bar', 'baz'], 'qux'],
});
which would cause a runtime error. Updated it to the correct format:
Model.findAll({
attributes: [['foo', 'baz'], ['baz', 'qux']],
});
to properly map field names to aliases.
Also fixed a similar issue in the next example on the same page, which used the same incorrect structure for the attributes option, the previous example showed:
Model.findAll({
attributes: ['foo', [sequelize.fn('COUNT', sequelize.col('hats')), 'n_hats'], 'bar'],
});
which causes the same runtime error. Updated it to the right format:
Model.findAll({
attributes: [['foo', 'bar'], [sequelize.fn('COUNT', sequelize.col('hats')), 'n_hats']],
});
These correction ensures valid syntax and clearer guidance for Sequelize users.