mongo支援表示式條件查詢

2021-09-26 07:33:22 字數 1449 閱讀 5979

通過相關表示式,如 concat, substr, tolower, toupper 等,對mongo進行操作;

並且可以根據操作結果進行條件判斷。

10.11.2. supported aggregation operations

此處以 substr為例。

@document(collection = "test")

public class input

public void setid(string id)

public string gettitle()

public void settitle(string title)

public string getcreatedtime()

public void setcreatedtime(string createdtime)

public string getupdatedtime()

public void setupdatedtime(string updatedtime)

}

public class output 

public void setid(string id)

public string gettitle()

public void settitle(string title)

public string getcreatedtime()

public void setcreatedtime(string createdtime)

public string getupdatedtime()

public void setupdatedtime(string updatedtime)

public string getcreateddate()

public void setcreateddate(string createddate)

}

@autowired

mongotemplate mongotemplate;

@test

public void testaggregation3()

相當於執行命令

db.getcollection('test').aggregate( } },

} },

, })

注:spring 列印的 語句如下:

# 需要替換 為數字 10 

} },

} }, }, }],

"cursor" : }

MySQL條件表示式case when查詢

先建立一張這樣的一張表user表 再建立一張成績表 需求是查詢到學生各科的成績,並劃分級別。成績大於等於60小於80屬於及格,成績大於80優秀,小於60為不及格 select u.user class as 班級 u.user number as 學號 u.user name as 姓名 s.sub...

pgsql條件表示式

postgresql 8.1 中文文件 prev fast backward chapter 9.函式和操作符 fast forward next 本節描述在 postgresql 裡可以用的sql相容的條件表示式。sqlcase 表示式是一種通用的條件表示式,類似於其它語言中的 if else 語...

Postgresql 條件表示式

postgresql中可用的sql相容的條件表示式。如果你的需求超過這些條件表示式的能力,你可能會希望用一種更富表現力的程式語言寫乙個儲存過程。sql case表示式是一種通用的條件表示式,類似於其它程式語言中的 if else 語句 case when condition then result ...