微信小程式 雲開發筆記

2021-10-18 17:36:45 字數 2169 閱讀 6692

獲取集合內所有的資料,一般只能獲取20條

db.collection(「集合名」).get().then(res =>)

獲取集合內具體id的資料

db.collection("集合名 ").doc(「id」).get().then(res=>)

3.獲取progress大於等於50的資料

const a=db.command

db.collection("").where().get().then(res=>)

單條資料

db.collection("").doc(「id」).remove().then(res=>)

.doc()裡面放的是id,如果不用id刪除資料可以不加

多條資料

多條資料(需要雲函式)。

如:db.collection(" ").where().remove().then(res=>)

這語句意思就是,在collection集合裡面,刪除title是helloworld的資料。

只有在雲函式中才可以刪除多條資料,和獲取超過20條資料上限的資料

多用於條件查詢

const a=db.command (要用command,先定義。)

db.collection(「集合」).where().get().then(res=>)

查詢author裡面有韓寒的資料。

command.lt( 小於),lte(小於等於 ), gt( 大於)

in(在…裡面查詢)

and (與)

單條資料更新

更新某個id的值

db.collection(「firstproject」).doc(「id」).update(

}).then(res=>)

2.多條資料更新(要用雲函式)

const cloud = require(『wx-server-sdk』)

cloud.init()

const db=cloud.database()

// 雲函式入口函式

exports.main = async (event, context) => ).update(})}

(不整理了,將就用了)

1.自增操作

command.inc:

_.inc(1)

2.運算元據庫陣列.

push,在陣列後面新增資料.

pop,最尾部的元素刪掉.

shift:刪除頭部元素

unshift 在最前面新增元素.

3.count函式

把get換成count

db.collection(「集合名」).where().count.then(res=>)

4.oderby

提供兩個字段,乙個是需要排序的字段,第二個是公升序還是降序。

沒有資料篩選的功能,會全部提供出來。沒有字段的話,會最先顯示出來。可以再鏈式乙個oderby提供其他欄位讓他排序。

5.limite

用get一次性·可以顯示20條資料,如果只想要十條,可以用limite(10)

skip: ----跳過***,常用與分頁 一般和limite一起使用。。

db.collection(「集合名」).skip(2).limite(2).then(res =>) /每頁兩條資料,獲取第二頁資料/

6.field —獲取指定字段,其他欄位不顯示.

db.collection(「集合名」).field().then(res=>)

正規表示式: /^***xx/,i(大小寫不敏感),也可以用db.regexp()

微信小程式開發筆記

元件開發 1 與vue 元件用法類似。a 建立元件 小程式中的元件與普通頁面目錄相同,例如需要建立乙個名為 component 的元件。首先建立乙個目錄為 component 的目錄,由 component.wxss component.wxml component.js component.jso...

微信小程式開發筆記 05

pages list list.wxss loadmore bindtap loadmore data lastid class loadmore 載入更多view 獲取應用例項 介面反饋提示 page loaddata function lastid return false var len re...

微信小程式開發筆記(三) 模板

為什麼要用模板呢?當多個頁面需要有一樣的元件時,使用模板會比較方便。table of contents 一 定義模板 使用模板 二 使用模板 三 列表渲染 模板 頁面傳值 1.列表渲染 2.template.wxml裡的模板 頁面傳值 3.js中的事件定義 使用 name 屬性,作為模板的名字。然後...