小编San*_*agi的帖子

React-redux : listening to state changes to trigger action

I have my redux state like this:

{
  parks: [
    {
      _id:"ad1esdad",
      fullName : "Some Name"
    },
    {
      _id:"ad1es3s",
      fullName : "Some Name2"
    }
  ],
  parkInfo: {
    id : "search Id",
    start_time : "Some Time",
    end_time : "Some Time"
  }
}
Run Code Online (Sandbox Code Playgroud)

I have a parkSelector component from which a user selects parkId and start_time and end_time

import React, { Component } from 'react';
import { changeParkInfo } from '../../Actions';

class ParkSelector extends Component {

  constructor(props) {
    super(props);

    this.handleApply = this.handleApply.bind(this); …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs redux react-redux

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

将元素插入MongoDB中的嵌套数组中

我是mongoDB的新手.我在更新mongoDB集合中的记录时遇到了一些麻烦.

如何将元素添加到数组"喜欢"到嵌入式记录中

我有一个嵌入式集合,如:

{
        "_id" : "iL9hL2hLauoSimtkM",
        "title" : "Some Topic",
        "followers" : [ 
            "userID1", 
            "userID2", 
            "userID3"
        ],
        "comments" : [ 
            {
                "comment" : "Yes Should be....",
                "userId" : "a3123",
                "likes" : [
                           "userID1",
                            "userID2"
                         ]
            }, 
            {
                "comment" : "No Should not be....",
                "userId" : "ahh21",
                "likes" : [
                           "userID1",
                           "userID2",
                           "userID3"
                         ]
            }
        ]
    }
Run Code Online (Sandbox Code Playgroud)

我想将记录更新为

{
        "_id" : "iL9hL2hLauoSimtkM",
        "title" : "Some Topic",
        "followers" : [ 
            "userID1", 
            "userID2", 
            "userID3"
        ],
        "comments" : [ 
            {
                "comment" : "Yes …
Run Code Online (Sandbox Code Playgroud)

mongodb meteor

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

Firebase云功能与批量更新不一致

我有我的firebase云功能,我在这里调用我的外部api端点.

const functions = require('firebase-functions');
var admin = require("firebase-admin");
admin.initializeApp(functions.config().firebase);
var request = require('request');
var moment = require('moment');
var rp = require('request-promise');

var db = admin.database();

exports.onCheckIn = functions.database.ref('/news/{newsId}/{entryId}')
      .onCreate(event => {
        console.log("Event Triggered");
        var eventSnapshot = event.data.val();
        request.post({
              url: 'http://MyCustomURL/endpoint/',
              form: {
                data: eventSnapshot.data
             }
            }, function(error, response, body){

                console.log(response);

            });



      })
Run Code Online (Sandbox Code Playgroud)

我正在使用Blaze计划,这是完全正常的.但问题是,当我创建批量数据(大约50到100个条目)时,我的自定义URL的HTTP请求无法正常工作.正在跳过一个或两个HTTP请求.

我调试了我的自定义服务器,发现它没有收到来自firebase的丢失请求.但我也检查了云功能日志,我发现每个事件都被正确触发.

可能是什么问题呢?我做错了吗?

http node.js firebase google-cloud-functions

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