控制台中的非托管模块错误

Unmanaged Module Error in Console

当我使用 apos.singleton 配置相同数据库名称的片段时,我的控制台出现了这个错误,但我设法使用 $unset 方法直接从数据库本身删除:

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
HEY DEVELOPER: the following types exist in your aposDocs collection,
but are not managed by any module. A generic manager is being stubbed in
for each one to keep your site from crashing, but you should remove thesepermanently from the database OR manage them properly by:

* Listing them as "types" for "apostrophe-pages", OR
* Providing an appropriate subclass of apostrophe-pieces.

portfolios, tryComment, trycomment

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

This happen everytime I restart node app.

它没有从数据库中完全删除吗?也许在垃圾桶里?我使用此代码直接删除非托管部分:

self.addTask('delete', 'Delete Query MongoDB', function (apos, argv, callback) {
  let req = self.apos.tasks.getAReq()
  return self.apos.docs.db.update({}, {
    $unset: {
      someDate: 1
    }
  }, {
    multi: true
  }, callback)
})

我真正的问题是,如何在每次重新启动时完全消除该错误 node app

我不确定您为什么使用 $unset 取消设置 someDate 属性,这与此问题无关。

问题是您的 aposDocs 集合中仍有文档将 type 属性 设置为 portfoliostryCommenttrycomment.

假设您真的希望它们消失,您可以通过这种方式删除它们(mongo shell 示例):

db.aposDocs.remove({ type: { $in: [ 'portfolios, 'tryComment', 'trycomment' ] } });

$unset与删除文档无关。它会取消保留在数据库中的文档的特定属性。