小编Tar*_*len的帖子

MongoError:虚线字段..对存储无效

我正在尝试使用以下查询更新具有匹配嵌套属性的文档

upsertByCommentThreadId: function(commentThread) {
    return CommentThreads.update({
         'youtube.commentThreadId': commentThread.youtube.commentThreadId 
      },
      {
        $set: commentThread
      },
      {
        upsert: true
      }
    );
  }
Run Code Online (Sandbox Code Playgroud)

架构:

Schema({
  youtube: {
    type: Object
  },
  'youtube.etag': {
    type: String
  },
  'youtube.commentThreadId': {
    type: String,
    index: 1
  },
  ...
Run Code Online (Sandbox Code Playgroud)

但是我收到了一个错误

Exception while invoking method ... MongoError: The dotted field 'youtube.commentThreadId' in 'youtube.commentThreadId' is not valid for storage.
Run Code Online (Sandbox Code Playgroud)

我不知道如果不是通过点表示法我还能查询嵌套属性

schema mongodb meteor

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

错误:流星代码必须始终在光纤内运行

我在我的应用程序中使用条带付款,我想在成功交易后在我自己的数据库中创建收据文档

我的代码:

Meteor.methods({
  makePurchase: function(tabId, token) {
    check(tabId, String);
    tab = Tabs.findOne(tabId);

    Stripe.charges.create({
      amount: tab.price,
      currency: "USD",
      card: token.id
    }, function (error, result) {
      console.log(result);
      if (error) {
        console.log('makePurchaseError: ' + error);
        return error;
      }

      Purchases.insert({
        sellerId: tab.userId,
        tabId: tab._id,
        price: tab.price
      }, function(error, result) {
        if (error) {
          console.log('InsertionError: ' + error);
          return error;
        }
      });
    });
  }
});
Run Code Online (Sandbox Code Playgroud)

但是,此代码返回错误:

Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with …
Run Code Online (Sandbox Code Playgroud)

meteor

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

OpenSSL::SSL::SSLError: SSL_connect 返回=1 errno=0 state=error: 证书验证失败

我在 Heroku 上托管了 Rails API 服务器,它向客户端初始 API 请求中指定的回调 url 发出异步 POST 请求。

当我尝试通过 SSL POST 到我的客户之一的 web 应用程序时遇到问题。

connection = Faraday::Connection.new('https://subdomain.some_client.com', ssl: { ca_file: '/usr/lib/ssl/certs/ca-certificates.crt' })
connection.get '/test'
Run Code Online (Sandbox Code Playgroud)

以下抛出错误:

Faraday::Error::ConnectionFailed: SSL_connect returned=1 errno=0 state=error: certificate verify failed
Run Code Online (Sandbox Code Playgroud)

但是,如果我通过 HTTPS 发布到另一台服务器,例如谷歌,它工作正常

connection = Faraday::Connection.new('https://www.google.com', ssl: { ca_file: '/usr/lib/ssl/certs/ca-certificates.crt' })
connection.get '/'
Run Code Online (Sandbox Code Playgroud)

这是否意味着错误出在客户端的 SSL 配置上?如果是这样,我如何帮助他们调试问题?

更新:

我可以毫无问题地将 POST 卷曲到客户端的 web 应用程序,只有当我通过 ruby​​ 的 HTTP 库执行它时才会失败

非常感谢谢谢

ssl ruby-on-rails faraday

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

rails 4.2升级后性能超级慢

我最近将rails从4.0.4升级到4.2,同样也是依赖.我在puma服务器上运行我的应用程序,我也将puma gem升级到最新的稳定版本.

问题是,在升级之后,我的大部分请求时间从1-2秒变为30+,导致Heroku超时

Puma连接文件

# Force heroku to bigger conenction pool
Rails.application.config.after_initialize do
  ActiveRecord::Base.connection_pool.disconnect!

  ActiveSupport.on_load(:active_record) do
    config = ActiveRecord::Base.configurations[Rails.env] || Rails.application.config.database_configuration[Rails.env]
    config['reaping_frequency'] = ENV['PUMA_DB_REAP_FREQ'] || 10 # Seconds
    config['pool']              = ENV['PUMA_DB_POOL'] || 20 # Puma can run up to 16 threads, perfect will be 80 (5x16), but heroku max is 20 for dev and basic
    ActiveRecord::Base.establish_connection(config)
  end
end
Run Code Online (Sandbox Code Playgroud)

Gemfile(只有相关的宝石)

source 'https://rubygems.org'
ruby '2.0.0'
gem 'puma', '2.10.2'
gem 'rails', '~> 4.2.0'
gem 'pg', '~> 0.18.0'
gem 'heroku'
gem 'responders', '~> 2.0' …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails heroku ruby-on-rails-4

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

React Native限制?

我对移动开发知之甚少,但在JS中编写本机移动应用程序的可能性让我感兴趣.

但是,如果我错了,请纠正我,但我认为React Native不会很快取代传统的本机代码.为什么会这样?React Native有哪些限制,阻止它取代传统的原生开发?

任何见解都非常感谢

mobile objective-c ios reactjs react-native

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

chrome不会让我访问localhost(谷歌搜索)

如何使用谷歌搜索的地址栏禁用chrome?

我无法在0.0.0.0:6000访问localhost,因为chrome认为它是谷歌搜索而不是网址

有任何想法吗?

google-chrome

9
推荐指数
3
解决办法
7107
查看次数

Docker容器消失不另行通知

我托管我的Web应用程序是使用Dokku的Docker容器。

有时(也许每1-2天)docker容器会消失(不显示when docker ps),结果我的服务器宕机了。

我还没有找到原因。

我正在寻找一种调试方法,有什么想法吗?

docker dokku

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

在本地运行staging DB时的OpenSSL :: Cipher :: CipherError

我刚刚将我们的登台服务器数据库复制到我的开发中,现在每当我加载任何数据时都会收到此错误

OpenSSL::Cipher::CipherError
Run Code Online (Sandbox Code Playgroud)

这发生在下面的代码中

credentials = encrypted_credentials.inject({}) do |hash, (key, value)|
   hash[key] = AESCrypt.decrypt(value, password) <-----------
   hash
end
Run Code Online (Sandbox Code Playgroud)

有谁知道这是为什么?

ruby ssl ruby-on-rails aes

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

Meteor autoform,钩前异步回调

我正在使用Autoform和Slingshot进行S3交互.当用户提交表单时,我想拦截进程,通过Slingshot将文件上传到S3,doc使用返回的对象扩展对象,downloadUrl然后返回新的更新文档,并继续自动化过程

我有以下代码:

{{#autoForm collection="Tabs" id="newTabForm" type="method" meteormethod="createTab"}}

   ...
    <div class="modal-body">
      <fieldset>
         {{> afFormGroup name='downloadUrl' type='file' class='file-bag'}}
    ...

AutoForm.hooks({
  newTabForm: {
    before: {
      insert: function(doc, template) {
        console.log(doc);
        var file     = $('.file-bag')[0].files[0];

        var self = this;
        uploader.send(file, function(error, downloadUrl) {
          if (error) { throw new Meteor.Error(error); }

          doc = _.extend(doc, { downloadUrl: downloadUrl });
          self.result(doc);
        });
      }
    },
 ....

Meteor.methods({
createTab: function(doc) {
  check(doc, TabSchema);

  var priceInCents = doc.price * 100;
  var extraTabAttributes = {
    userId: Meteor.userId(), …
Run Code Online (Sandbox Code Playgroud)

meteor meteor-slingshot

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

焦点内容可编辑的div

我想聚焦 contenteditable div,这样我就可以在插入 DOM 时自动开始输入

我试过了$('.content').focus(),但这不起作用

示例 html:

<div class="content" contenteditable="true">sample input</div>
Run Code Online (Sandbox Code Playgroud)

html javascript jquery reactjs

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