<commit_before>let base = require("./base");
const validate = require("./validate");

module.exports = class extends base{
  constructor(api){
    super();
    this.api = api;
    this.definitions = api.definitions;
  }

  updateDocument(modelName){
    return async (ctx, next) => {
      await next();
      let model = ctx.models[modelName];
      ctx.body = await model.update({
        _id: ctx.params._id
      },{
        $set: ctx.is("formData") ? ctx.request.body.fields : ctx.request.body;
      });<commit_msg>Fix: 處理post & patch識別formData錯誤的問題<commit_after>let base = require("./base");
const validate = require("./validate");

module.exports = class extends base{
  constructor(api){
    super();
    this.api = api;
    this.definitions = api.definitions;
  }

  updateDocument(modelName){
    return async (ctx, next) => {
      await next();
      let model = ctx.models[modelName];
      ctx.body = await model.update({
        _id: ctx.params._id
      },{
        $set: ctx.is("formData") ? ctx.request.body.fields : ctx.request.body
      });
{'fraction_non_alphanumeric': 0.1553672316384181, 'fraction_numerical': 0.0, 'mean_word_length': 2.823741007194245, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7504851', 'n_tokens_mistral': 340, 'n_tokens_neox': 340, 'n_words': 72}