Skip to content

修改


  • @param whereObj 限制条件
  • @param updateObj 更新数据
  • (whereObj: DBOBJECT, updateObj: DBOBJECT)

update()

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) => {
    MDb(mongoConfig).M(user).update({
        username: '张三'
    },{
        $set: {
            username: '李四'
        }
    })
    return true
})
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) => {
    MDb(mongoConfig).M(user).update({
        username: '张三'
    },{
        $set: {
            username: '李四'
        }
    })
    return true
})

备案号:冀ICP备20015584号-2