小编aut*_*xer的帖子

什么是事件监听器上的捕获模式

事件修饰符下的vue文档中,有一个调用的示例,capture其中包含以下内容:

<!-- use capture mode when adding the event listener -->
<div v-on:click.capture="doThis">...</div>
Run Code Online (Sandbox Code Playgroud)

我已经做了一些搜索,但是没有找到关于如何修改事件绑定的明确答案,然后我想到了自己'你知道谁总能找到答案吗?堆栈溢出'

vue.js

14
推荐指数
2
解决办法
5438
查看次数

MongoDB dup key: { : null }

我没有太多 MongoDB 经验,并且我在使用 mLab 实例时遇到以下问题:

E11000 duplicate key error index: development.users.$key_1 dup key: { : null } MongoError: E11000 duplicate key error index: development.users.$key_1 dup key: { : null }

我尝试按key字段排序,寻找null密钥,但不确定应该如何查找重复的null密钥。让这件事变得困难的是,我什至不知道要搜索谷歌或堆栈溢出来解决这个问题。任何帮助将不胜感激,以下是完整的错误:

Mongoose model 'index-single-done' event fired on 'Family' for index:
Object {key: 1}

With error:
    E11000 duplicate key error index: development.users.$key_1 dup key: { : null } MongoError: E11000 duplicate key error index: 
development.users.$key_1 dup key: { : null }
at Function.MongoError.create (/Users/myUserName/development/projectName/node_modules/mongodb-core/lib/error.js:31:11)
at …
Run Code Online (Sandbox Code Playgroud)

mongodb

6
推荐指数
1
解决办法
4257
查看次数

提高 mongo 查询性能

我正在使用名为 Keystone 的基于节点的 CMS 系统,该系统使用 MongoDB 作为数据存储,从而对数据和访问提供相当自由的控制。我有一个非常复杂的模型,称为Family,它有大约 250 个字段、一堆关系和十几个方法。我的网站上有一个表单,允许用户输入所需的信息来创建新的家庭记录,但是处理时间很长(在本地主机上为 12 秒,在我的 Heroku 实例上超过 30 秒)。我遇到的问题是 Heroku 对于运行超过 30 秒的任何进程都会发出应用程序错误,这意味着我需要优化我的查询。除一项功能外,所有处理都发生得非常快。下面是有问题的函数:

const Family = keystone.list( 'Family' );

exports.getNextRegistrationNumber = ( req, res, done ) => {

    console.time('get registration number');

    const locals = res.locals;

    Family.model.find()
        .select( 'registrationNumber' )
        .exec()
        .then( families => {

            // get an array of registration numbers
            const registrationNumbers = families.map( family => family.get( 'registrationNumber' ) );

            // get the largest registration number
            locals.newRegistrationNumber = Math.max( …
Run Code Online (Sandbox Code Playgroud)

mongodb node.js keystonejs

3
推荐指数
1
解决办法
862
查看次数

标签 统计

mongodb ×2

keystonejs ×1

node.js ×1

vue.js ×1