• <i id='HrAid'><tr id='HrAid'><dt id='HrAid'><q id='HrAid'><span id='HrAid'><b id='HrAid'><form id='HrAid'><ins id='HrAid'></ins><ul id='HrAid'></ul><sub id='HrAid'></sub></form><legend id='HrAid'></legend><bdo id='HrAid'><pre id='HrAid'><center id='HrAid'></center></pre></bdo></b><th id='HrAid'></th></span></q></dt></tr></i><div id='HrAid'><tfoot id='HrAid'></tfoot><dl id='HrAid'><fieldset id='HrAid'></fieldset></dl></div>
    <tfoot id='HrAid'></tfoot>

    <small id='HrAid'></small><noframes id='HrAid'>

      <bdo id='HrAid'></bdo><ul id='HrAid'></ul>
        <legend id='HrAid'><style id='HrAid'><dir id='HrAid'><q id='HrAid'></q></dir></style></legend>

        Sequelize - 在 PostgreSQL 数组查询中不包含字符串

        Sequelize - does not contain a string within a PostgreSQL array query(Sequelize - 在 PostgreSQL 数组查询中不包含字符串)

        <small id='CKTAC'></small><noframes id='CKTAC'>

                <tbody id='CKTAC'></tbody>

                <bdo id='CKTAC'></bdo><ul id='CKTAC'></ul>

                <tfoot id='CKTAC'></tfoot>
                1. <i id='CKTAC'><tr id='CKTAC'><dt id='CKTAC'><q id='CKTAC'><span id='CKTAC'><b id='CKTAC'><form id='CKTAC'><ins id='CKTAC'></ins><ul id='CKTAC'></ul><sub id='CKTAC'></sub></form><legend id='CKTAC'></legend><bdo id='CKTAC'><pre id='CKTAC'><center id='CKTAC'></center></pre></bdo></b><th id='CKTAC'></th></span></q></dt></tr></i><div id='CKTAC'><tfoot id='CKTAC'></tfoot><dl id='CKTAC'><fieldset id='CKTAC'></fieldset></dl></div>
                  <legend id='CKTAC'><style id='CKTAC'><dir id='CKTAC'><q id='CKTAC'></q></dir></style></legend>
                  本文介绍了Sequelize - 在 PostgreSQL 数组查询中不包含字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个名为 Staff 的 Sequelize 模型.上面有一个数组字段,描述如下:

                  I have a Sequelize model called Staff. On it there's an array field described as follows:

                  const Staff = sequelize.define("staff", {
                      name: {
                          type: DataTypes.STRING,
                      },
                      email: {
                          type: DataTypes.STRING,
                          unique: true
                      },
                      password: {
                          type: DataTypes.STRING,
                      },
                      roles: {
                          type: DataTypes.ARRAY(DataTypes.STRING)
                      },
                  });
                  

                  我正在尝试创建一个 GraphQL 端点,它为所有在其 roles 字段中没有instructor"的员工提供服务.

                  I'm trying to create a GraphQL end point which serves up all staff which don't have 'instructor' in their roles field.

                  我已阅读 this page of the docs,建议我使用Sequelize.Op的组合.所以我创建了这个:

                  I've read this page of the docs, suggesting that I use a combination of Sequelize.Op. So I created this:

                  return Staff.findAll({
                          where: {
                              roles: {
                                  [Sequelize.Op.not]: {[Sequelize.Op.contains]: ['instructor']},
                              }
                          }
                      }
                  )
                  

                  上面抛出错误:

                  "message": "values.map is not a function"
                  

                  但是,如果我要尝试不是组合的查询,例如:

                  However, if I am to try a query which isn't a combo such as:

                  return models.Staff.findAll({
                          where: {
                              roles: {
                                  [Sequelize.Op.contains]: ['instructor']
                              }
                          }
                      }
                  )
                  

                  查询运行正常,这让我相信我可能有语法错误或对 Op 逻辑如何组合的误解.

                  The query runs properly, this leads me to believe I perhaps have a syntax error or misunderstanding of how Op logic is combined.

                  推荐答案

                  试试这个:

                  return models.Staff.findAll({
                    where: {
                      $not: {
                        roles: {
                          $contains: ['instructor'],
                        },
                      },
                    },
                  })
                  

                  子句 $not 必须在您的目标列之前.

                  The clause $not need to be prior than the column you target.

                  这篇关于Sequelize - 在 PostgreSQL 数组查询中不包含字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                  Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                  How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                  How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                  How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)
                  How to get number of video views with YouTube API?(如何使用 YouTube API 获取视频观看次数?)
                2. <i id='50pWO'><tr id='50pWO'><dt id='50pWO'><q id='50pWO'><span id='50pWO'><b id='50pWO'><form id='50pWO'><ins id='50pWO'></ins><ul id='50pWO'></ul><sub id='50pWO'></sub></form><legend id='50pWO'></legend><bdo id='50pWO'><pre id='50pWO'><center id='50pWO'></center></pre></bdo></b><th id='50pWO'></th></span></q></dt></tr></i><div id='50pWO'><tfoot id='50pWO'></tfoot><dl id='50pWO'><fieldset id='50pWO'></fieldset></dl></div>

                  1. <tfoot id='50pWO'></tfoot>
                        <tbody id='50pWO'></tbody>

                      <small id='50pWO'></small><noframes id='50pWO'>

                    1. <legend id='50pWO'><style id='50pWO'><dir id='50pWO'><q id='50pWO'></q></dir></style></legend>
                        <bdo id='50pWO'></bdo><ul id='50pWO'></ul>