av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

創(chuàng)新互聯(lián)小程序教程:微信小程序云開發(fā)服務(wù)端數(shù)據(jù)庫API查詢篩選條件

db.command.eq

查詢篩選條件,表示字段等于某個值。eq 指令接受一個字面量 (literal),可以是 number, boolean, string, object, array。

堅守“ 做人真誠 · 做事靠譜 · 口碑至上 · 高效敬業(yè) ”的價值觀,專業(yè)網(wǎng)站建設(shè)服務(wù)10余年為成都發(fā)電機租賃小微創(chuàng)業(yè)公司專業(yè)提供成都定制網(wǎng)頁設(shè)計營銷網(wǎng)站建設(shè)商城網(wǎng)站建設(shè)手機網(wǎng)站建設(shè)小程序網(wǎng)站建設(shè)網(wǎng)站改版,從內(nèi)容策劃、視覺設(shè)計、底層架構(gòu)、網(wǎng)頁布局、功能開發(fā)迭代于一體的高端網(wǎng)站建設(shè)服務(wù)。

方法簽名:

function eq(value: any): Command

比如篩選出所有自己發(fā)表的文章,除了用傳對象的方式:

const myOpenID = 'xxx'
db.collection('articles').where({
  _openid: myOpenID
})

還可以用指令:

const _ = db.command
const myOpenID = 'xxx'
db.collection('articles').where({
  _openid: _.eq(openid)
})

注意 eq 指令比對象的方式有更大的靈活性,可以用于表示字段等于某個對象的情況,比如:

// 這種寫法表示匹配 stat.publishYear == 2018 且 stat.language == 'zh-CN'
db.collection('articles').where({
  stat: {
    publishYear: 2018,
    language: 'zh-CN'
  }
})
// 這種寫法表示 stat 對象等于 { publishYear: 2018, language: 'zh-CN' }
const _ = db.command
db.collection('articles').where({
  stat: _.eq({
    publishYear: 2018,
    language: 'zh-CN'
  })
})

示例代碼

const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
  try {
    return await db.collection('articles').where({
      stat: _.eq({
        publishYear: 2018,
        language: 'zh-CN'
      })
    })
    .get()
  } catch(e) {
    console.error(e)
  }
}

db.command.neq

表示字段不等于某個值,和 db.command.eq 相反


db.command.lt

查詢篩選條件,表示字段需小于指定值。

方法簽名:

function lt(value: number): Command

示例代碼

找出進度小于 50 的 todo

const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
  try {
    return await db.collection('todos').where({
      progress: _.lt(50)
    })
    .get()
  } catch(e) {
    console.error(e)
  }
}

db.command.lte

查詢篩選條件,表示字段需小于或等于指定值。

方法簽名:

function lte(value: number): Command

示例代碼

找出進度小于或等于 50 的 todo

const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
  try {
    return await db.collection('todos').where({
      progress: _.lte(50)
    })
    .get()
  } catch(e) {
    console.error(e)
  }
}

db.command.gt

查詢篩選條件,表示字段需大于指定值。

方法簽名:

function gt(value: number): Command

示例代碼

找出進度大于 50 的 todo

const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
  try {
    return await db.collection('todos').where({
      progress: _.gt(50)
    })
    .get()
  } catch(e) {
    console.error(e)
  }
}

db.command.gte

查詢篩選條件,表示字段需大于或等于指定值。

方法簽名:

function gte(value: number): Command

示例代碼

找出進度大于或等于 50 的 todo

const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
  try {
    return await db.collection('todos').where({
      progress: _.gte(50)
    })
    .get()
  } catch(e) {
    console.error(e)
  }
}

db.command.in

查詢篩選條件,表示字段的值需在給定的數(shù)組內(nèi)。

方法簽名:

function in(values: any[]): Command

示例代碼

找出進度為 0 或 100 的 todo

const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
  try {
    return await db.collection('todos').where({
      progress: _.in([0, 100])
    })
    .get()
  } catch(e) {
    console.error(e)
  }
}

db.command.in

查詢篩選條件,表示字段的值需不在給定的數(shù)組內(nèi)。

方法簽名:

function nin(values: any[]): Command

示例代碼

找出進度不是 0 或 100 的 todo

const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
  try {
    return await db.collection('todos').where({
      progress: _.nin([0, 100])
    })
    .get()
  } catch(e) {
    console.error(e)
  }
}

db.command.nin

支持端:小程序 , 云函數(shù) , Web

查詢篩選操作符,表示要求值不在給定的數(shù)組內(nèi)。

參數(shù)

value: any[]

返回值

Command

示例代碼

找出進度不是 0 或 100 的 todo

const _ = db.command
db.collection('todos').where({
  progress: _.nin([0, 100])
})
.get({
  success: console.log,
  fail: console.error
})

本文標(biāo)題:創(chuàng)新互聯(lián)小程序教程:微信小程序云開發(fā)服務(wù)端數(shù)據(jù)庫API查詢篩選條件
鏈接分享:http://uogjgqi.cn/article/dppdppd.html
掃二維碼與項目經(jīng)理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流