Code Monkey home page Code Monkey logo

Comments (1)

qknow-w avatar qknow-w commented on July 19, 2024

patch.js

"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});

exports["default"] = function (req, MongooseModel) {
return new Promise(function (resolve, reject) {
if (!Object.keys(req.body).length) {
return reject({ status: 422 });
}
MongooseModel.findOneAndUpdate({ _id: req.params.id },req.body,{"new":true},function(err,entity){
if (err) {
return reject(err);
}
return resolve({ status: 201, entity: entity });
});
});
};

module.exports = exports["default"];

使用:

//更新子文档

    var f=$.ajax({
        url:"http://127.0.0.1:3000/activities(dc7f134c-1f93-454a-970f-cb962dc2bf84)",
        type:"patch",
        data:{"creatInfo.perple":"eeeee","updateInfo.perple":"weiyang"}
    });
    f.then(function(result){
        console.log(result);
    },function(err){
        console.log(err);
    })

});

/*// 更新子数组
$(function(){
var f=$.ajax({
url:"http://127.0.0.1:3000/activities(dc7f134c-1f93-454a-970f-cb962dc2bf84)",
type:"patch",
data:{"images.poster.0":"wwww.vaid.com"}
});
f.then(function(result){
console.log(result);
},function(err){
console.log(err);
})

from node-odata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.