查询
- @param
whereObj
限制条件 - @param
current
第几页 - @param
size
每页多少条 - (whereObj: DBOBJECT = {}, current?: number, size?: number)
select()
const mongoConfig = {
host: '127.0.0.1',
port: 27017,
user: '',
password: '',
database: ''
}
// 定义模型
const user = {
username: String,
age: Number
}
import { MDb } from 'think-ts-db'
export default defineEventHandler(async (event) => {
const user = await MDb(mongoConfig).M(user).select({
age: 18
}, 1, 20)
return user
})
const mongoConfig = {
host: '127.0.0.1',
port: 27017,
user: '',
password: '',
database: ''
}
// 定义模型
const user = {
username: String,
age: Number
}
import { MDb } from 'think-ts-db'
export default defineEventHandler(async (event) => {
const user = await MDb(mongoConfig).M(user).select({
age: 18
}, 1, 20)
return user
})