小编iam*_*dri的帖子

如果数组存在则将对象推入数组,否则在MongoDB中使用对象创建数组

我收集了这样的文件:

{
    _id : "abcd",
    name : "Tom",
    myArray : [
        {
            field1 : "",
            field2 : ""
        }
    ]
},
{
    _id : "efgh",
    name : "Jerry"
}
Run Code Online (Sandbox Code Playgroud)

我有一个新的对象myArray.我想编写一个查询来只更新一个文档.

如果查询与文档匹配_id : "abcd",则将新对象推入myArray字段:

{
    _id : "abcd",
    name : "Tom",
    myArray : [
        {
            field1 : "",
            field2 : ""
        },
        {
            // new object
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

如果查询匹配,则在其中_id : "efgh"创建myArray包含新对象的字段:

{
    _id : "efgh",
    name : "Jerry"
    myArray : …
Run Code Online (Sandbox Code Playgroud)

mongodb mongodb-query

12
推荐指数
2
解决办法
1万
查看次数

Firebase Cloud Messaging: "undefined" database getting created in IndexedDB

I am implementing web push notification with Firebase Cloud Messaging (FCM). I have followed the documentation for setup a javascript firebase cloud messaging and completed initial implementation for my app. I am able to receive messages from firebase. But, I noticed that a database has created in IndexedDB and it named as undefined. This database contains a single store called fcm_token_object_Store, which all auth, endpoint, fcmSenderId, fcmToken, etc.

Please refer the following screenshot:

在此处输入图片说明

Question: Can this database_name …

firebase web-push firebase-cloud-messaging

5
推荐指数
0
解决办法
245
查看次数

即使模板在流星中被销毁,$(window).scroll(...)也在运行

我有两个单独的模板,在两个模板中(渲染)我正在做$(窗口).scroll()但是然后转到另一个模板,$(窗口).scroll()从两个,先前和当前运行模板.

代码片段如下:

dashboard1.js

Template.dashboard1.rendered = function(){
    $(window).scroll(function() {
        console.log('dashboard1 scroll');
        //... doing pagination and sticky element for dashboard1
    });
}

Template.dashboard1.destroyed = function(){
    console.log('dashboard1 destroyed');
}
Run Code Online (Sandbox Code Playgroud)

dashboard2.js

Template.dashboard2.rendered = function(){
    $(window).scroll(function() {
        console.log('dashboard2 scroll');
        //... doing pagination and sticky element for dashboard2
    });
}

Template.dashboard2.destroyed = function(){
    console.log('dashboard2 destroyed');
}
Run Code Online (Sandbox Code Playgroud)

安慰:

dashboard1 destroyed
dashboard2 scroll
dashboard1 scroll
dashboard2 scroll
dashboard1 scroll
dashboard2 scroll
Run Code Online (Sandbox Code Playgroud)

但是,如果我刷新浏览器,那么它只来自当前模板.

为什么会发生这种想法?解决这个问题的方法是什么?

javascript jquery templates meteor meteorite

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