S
S
Sergey Melodin2019-09-12 20:03:12
ORM
Sergey Melodin, 2019-09-12 20:03:12

How sequelize.fn works?

I read the doc, read the source code, googled carefully, but could not understand the power of this function. Does it call functions written inside the database (like those created through create functionpostgres) + some built-in ones, or does it allow you to write custom functions at the code level that extend the behavior and allow you not to introduce logic into the database?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Shvets, 2019-09-12
@melodyn

First option. Here is an example from their docs

Model.findAll({
  attributes: 
});

In practice, it is easier to use sequelize.queryand in general, the fewer sequelizations, the better. Debugging it is still an adventure. Especially if someone actively used scope and instance methods.

M
Mikhail, 2019-09-12
@makarychev13

Here is an example.
How would you write this method without fn?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question