2017-06-06 43 views
0

我创建了一个模型梯形校正错误 - 你不能更新人口的关系

newProject = new Project.model({ 

    licensee:   req.query.licensee ? req.query.licensee : '', 
    webUrl:    req.query.webUrl ? req.query.webUrl : '', 
    appName:   req.query.appName ? req.query.appName : '', 
    licenseDesktop:  req.query.cart.license.desktop.quantity ? req.query.cart.license.desktop.quantity : '', 
    licenseDesktopLabel:req.query.cart.license.desktop.label ? req.query.cart.license.desktop.label : '', 
    licenseWeb:   req.query.cart.license.web.quantity ? req.query.cart.license.web.quantity : '', 
    licenseWebLabel: req.query.cart.license.web.label ? req.query.cart.license.web.label : '', 
    licenseApp:   req.query.cart.license.app.quantity ? req.query.cart.license.app.quantity : '', 
    licenseAppLabel: req.query.cart.license.app.label ? req.query.cart.license.app.label : '', 
    collections:  req.query.cart.collections, 
    pairs:    req.query.cart.pairs, 
    fonts:    req.query.cart.fonts, 
    downloadName:  downloadName, 
    fileCreated:  false 
}); 

这似乎是正确的结构化

{ 
    licensee: 'wer', 
    webUrl: '', 
    appName: '', 
    mindate: 0, 
    fileCreated: 'false', 
    cost: 0, 
    downloadName: 'wer-68201706172956354', 
    fonts: 
    [ { _id: 55945f1e67c1b9371e2b1241, 
      __v: 0, 
      createdAt: Wed Jul 01 2015 14:43:58 GMT-0700 (PDT), 
      createdBy: 558c02e92e1093453a504a0e, 
      description: '', 
      slug: 'fort-thin', 
      sortOrder: 14, 
      title: 'Fort Thin', 
      tokens: [], 
      trackingAmount: '', 
      trackingChange: '', 
      typefaceName: 'Fort', 
      updatedAt: Sun Jul 03 2016 10:28:35 GMT-0700 (PDT), 
      updatedBy: 55df7e156bee0c7728109df9, 
      weightName: 'Thin', 
      price: 50, 
      sell: true, 
      style: 'Normal', 
      weight: '100', 
      otfFile: [Object], 
      ttfFile: [Object], 
      eotFile: [Object], 
      woffFile: [Object], 
      onHomepage: 'show' }, 
     { _id: 55c073bfe490ca292ae80814, 
      __v: 0, 
      createdAt: Tue Aug 04 2015 01:11:43 GMT-0700 (PDT), 
      createdBy: 558c02e92e1093453a504a0e, 
      description: '', 
      slug: 'fort-thin-italic', 
      sortOrder: 15, 
      title: 'Fort Thin Italic', 
      tokens: [], 
      trackingAmount: '', 
      trackingChange: '', 
      typefaceName: 'Fort', 
      updatedAt: Sun Jul 03 2016 10:28:56 GMT-0700 (PDT), 
      updatedBy: 55df7e156bee0c7728109df9, 
      weightName: 'Thin', 
      price: 50, 
      sell: true, 
      style: 'Italic', 
      weight: '100', 
      otfFile: [Object], 
      ttfFile: [Object], 
      eotFile: [Object], 
      woffFile: [Object], 
      onHomepage: 'show' } ], 
    pairs: 
    [ { _id: 574dfc9a7c2cb9a32819d2b1, 
      __v: 1, 
      createdAt: Tue May 31 2016 14:05:30 GMT-0700 (PDT), 
      createdBy: 55df7e156bee0c7728109df9, 
      slug: 'fort-thins', 
      sortOrder: 3, 
      title: 'Fort Thins', 
      titleStyle: 55945f1e67c1b9371e2b1241, 
      updatedAt: Tue May 31 2016 14:08:21 GMT-0700 (PDT), 
      updatedBy: 55df7e156bee0c7728109df9, 
      price: 75, 
      sell: true, 
      fonts: [Object], 
      autoStyle: true } ], 
    collections: [], 
    licenseAppLabel: '0 applications', 
    licenseApp: '0', 
    licenseWebLabel: '0 visitors/month', 
    licenseWeb: '0', 
    licenseDesktopLabel: 'Up to 3 computers', 
    licenseDesktop: '1', 
    _id: 5935f784c69f58a58003ff6c 
} 

但是当我运行

var updater = newProject.getUpdateHandler(req, res, { 

     errorMessage: 'There was an error creating your new project.' 
    }); 

updater.process(req.body, { 

    flashErrors: true, 
    logErrors: true 
}, function(err) { 

    if (err) { 

     console.log("There was an error updating your account. "); 
    } 
    next(); 
}); 

我收到一个错误(错误:fieldTypes.relationship.updateItem()错误 - 您无法更新填充关系。)

它似乎在newProject.getUpdateHandler上触发。我似乎无法解决这个错误,我使用keystone 4.0,有没有人有任何想法?

回答

0

这似乎解决了这个问题..但我觉得这不是正确的答案。

newProject.save(function(err) { 

    if (err) { 

     logError(err, "There was an error updating your account. "); 
    } 
    next(); 
});