Skip to content

Is it possible to use sequelize operators (symbols) #38

Description

@marc-at

Sequelize now recommends using operators, which are javascript Symbols.

http://docs.sequelizejs.com/manual/tutorial/querying.html#operators-security

This causes a problem, because Symbols are ignored by JSON.stringify and Object.keys.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol

This cache implementation uses CircularJSON to generate the cache key, so it doesn't work when using Symbols as keys.
https://www.npmjs.com/package/circular-json

Has anyone investigated a way to generate cache keys that includes Symbols?

If you need an example of this, I can provide one. To test without that, you can use the key function from Cacher:

  hash = crypto.createHash('sha1')
    .update(CircularJSON.stringify(this.options, jsonReplacer))
    .digest('hex');

the where object to pass would be something like

{
 [Op.or]: [
    {firstName: {[Op.like]: 'test'}},
    {lastName: {[Op.like]: 'test'}}
  ]
}

instead of

{
 $or: [
    {firstName: {$like: 'test'}},
    {lastName: {$like: 'test'}}
  ]
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions