問題タブ [moped]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
0 に答える
60 参照

ruby-on-rails - モデルを使用せずに文字列からタイムスタンプへの Mongoid 移行更新フィールド

実際には日付の文字列表現を持つコレクションのフィールドを更新し、それを ISODate に変更したいと考えています。

私はすでに解決策を持っていますが、それは非効率的です:

レコードごとに検索して更新するのではなく、1回の操作で更新したいと考えています。

0 投票する
1 に答える
35 参照

ruby-on-rails - 1 回の操作でモンゴイド ドキュメントのコレクションを格納する

gemを使用する場合Moped、ハッシュの配列を次のように格納できます。

Mongoid ドキュメントでは、次のようになります。

これは、それぞれの挿入操作を意味します。シングルオペレーション方式を維持する方法をご存知ですか?での取引のようなものでしょActiveRecordうか?

0 投票する
1 に答える
72 参照

ruby - ルビーモンゴイドアプリでモペット挿入ランタイムを測定するには?

現在、モペット クエリのランタイムを監視するために、モペット ログ パーサーを作成しています。実行時パラメーターを使用する QUERY コマンドではうまく機能しますが、INSERT と UPDATE には実行時パラメーターがありません。すべての INSERT と UPDATE の後には、ランタイムを含むgetLastError COMMAND が続きます。

原付ログのサンプルを次に示します。

ランタイムを使用したクエリ

ランタイムなしの INSERT で COMMAND あり

COMMAND ランタイムは getlasterror 呼び出し用であり、INSERT 呼び出し用ではないと確信しています。INSERT クエリのこのランタイム情報を取得する方法はありますか?

0 投票する
0 に答える
50 参照

mongodb - Moped 2.0.7 未定義のメソッド「セッション」

ここで何が起こっているのかわかりません。私は MOPED 2.0.7 にアップグレードし、この未定義のメソッド「セッション」を取得しています #

次に、こちらのドキュメントによると、次のことができるはずです。

しかし、私がそうするとき、私は得る

何か案は?

0 投票する
1 に答える
139 参照

ruby-on-rails-3 - Resque ワーカーで断続的に発生する "Moped::Protocol::Command failed with error nil" エラー

Rails 3.2、Mongoid 3.1.7、Moped 1.5.3、および Resque 1.24.1 を使用しています。

Resque ワーカーで "Moped::Protocol::Command failed with error nil" [1] エラーが繰り返し発生します。

This issueとMoped repo のthis oneから、これはおそらく Resque のフォークが原因だと思われますが、どちらも私が使用しているよりも古いバージョンの Moped に関するものであり、特定の特定の情報を見つけることができませんでした。 Mongoid でうまく動作するように Resque を構成します。

Resque ワーカーのエラーを解決するにはどうすればよいですか?

[1] 完全なエラー: Exception: Moped::Errors::OperationFailure Error: The operation: #<Moped::Protocol::Command @length=58 @request_id=3 @response_to=0 @op_code=2004 @flags=[] @full_collection_name="admin.$cmd" @skip=0 @limit=-1 @selector={:ismaster=>1} @fields=nil> failed with error nil /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/node.rb:99:in `block in command' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/node.rb:600:in `[]' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/node.rb:600:in `block (3 levels) in flush' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/node.rb:599:in `map' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/node.rb:599:in `block (2 levels) in flush' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/node.rb:150:in `ensure_connected' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/node.rb:595:in `block in flush' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/node.rb:610:in `logging' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/node.rb:594:in `flush' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/node.rb:583:in `process' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/node.rb:92:in `command' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/node.rb:409:in `refresh' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/cluster.rb:171:in `block in refresh' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/cluster.rb:185:in `each' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/cluster.rb:185:in `refresh' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/cluster.rb:135:in `nodes' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/cluster.rb:206:in `with_primary' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/session/context.rb:108:in `with_node' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/cursor.rb:137:in `load_docs' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/cursor.rb:25:in `each' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/query.rb:76:in `each' /shared/bundle/ruby/2.2.0/gems/moped-1.5.3/lib/moped/query.rb:76:in `each' /shared/bundle/ruby/2.2.0/gems/mongoid-3.1.7/lib/mongoid/contextual/mongo.rb:423:in `entries' /shared/bundle/ruby/2.2.0/gems/mongoid-3.1.7/lib/mongoid/contextual/mongo.rb:423:in `check_existence' /shared/bundle/ruby/2.2.0/gems/mongoid-3.1.7/lib/mongoid/contextual/mongo.rb:146:in `exists?' /shared/bundle/ruby/2.2.0/gems/mongoid-3.1.7/lib/mongoid/contextual.rb:19:in `exists?' /shared/bundle/ruby/2.2.0/gems/mongoid-3.1.7/lib/mongoid/validations/uniqueness.rb:273:in `validate_root' /shared/bundle/ruby/2.2.0/gems/mongoid-3.1.7/lib/mongoid/validations/uniqueness.rb:52:in `block in validate_each' /shared/bundle/ruby/2.2.0/gems/mongoid-3.1.7/lib/mongoid/validations/queryable.rb:23:in `with_query' /shared/bundle/ruby/2.2.0/gems/mongoid-3.1.7/lib/mongoid/validations/uniqueness.rb:46:in `validate_each' /shared/bundle/ruby/2.2.0/gems/activemodel-3.2.22/lib/active_model/validator.rb:153:in `block in validate' /shared/bundle/ruby/2.2.0/gems/activemodel-3.2.22/lib/active_model/validator.rb:150:in `each' /shared/bundle/ruby/2.2.0/gems/activemodel-3.2.22/lib/active_model/validator.rb:150:in `validate' /shared/bundle/ruby/2.2.0/gems/activesupport-3.2.22/lib/active_support/callbacks.rb:310:in `_callback_before_265' /shared/bundle/ruby/2.2.0/gems/activesupport-3.2.22/lib/active_support/callbacks.rb:418:in `_run__123721054543109017__validate__3207805434451540367__callbacks' /shared/bundle/ruby/2.2.0/gems/activesupport-3.2.22/lib/active_support/callbacks.rb:405:in `__run_callback' /shared/bundle/ruby/2.2.0/gems/activesupport-3.2.22/lib/active_support/callbacks.rb:385:in `_run_validate_callbacks' /shared/bundle/ruby/2.2.0/gems/activesupport-3.2.22/lib/active_support/callbacks.rb:81:in `run_callbacks' /shared/bundle/ruby/2.2.0/gems/mongoid-3.1.7/lib/mongoid/callbacks.rb:130:in `run_callbacks' /shared/bundle/ruby/2.2.0/gems/activemodel-3.2.22/lib/active_model/validations.rb:228:in `run_validations!' /shared/bundle/ruby/2.2.0/gems/activemodel-3.2.22/lib/active_model/validations/callbacks.rb:53:in `block in run_validations!' /shared/bundle/ruby/2.2.0/gems/activesupport-3.2.22/lib/active_support/callbacks.rb:403:in `_run__123721054543109017__validation__3207805434451540367__callbacks' /shared/bundle/ruby/2.2.0/gems/activesupport-3.2.22/lib/active_support/callbacks.rb:405:in `__run_callback' /shared/bundle/ruby/2.2.0/gems/activesupport-3.2.22/lib/active_support/callbacks.rb:385:in `_run_validation_callbacks' /shared/bundle/ruby/2.2.0/gems/activesupport-3.2.22/lib/active_support/callbacks.rb:81:in `run_callbacks' /shared/bundle/ruby/2.2.0/gems/mongoid-3.1.7/lib/mongoid/callbacks.rb:130:in `run_callbacks' /shared/bundle/ruby/2.2.0/gems/activemodel-3.2.22/lib/active_model/validations/callbacks.rb:53:in `run_validations!' /shared/bundle/ruby/2.2.0/gems/activemodel-3.2.22/lib/active_model/validations.rb:195:in `valid?' /shared/bundle/ruby/2.2.0/gems/mongoid-3.1.7/lib/mongoid/validations.rb:84:in `valid?' /releases/20160315172839/app/performers/garmin_receive_push.rb:11:in `block in perform' /releases/20160315172839/app/performers/garmin_receive_push.rb:9:in `map' /releases/20160315172839/app/performers/garmin_receive_push.rb:9:in `perform'

0 投票する
1 に答える
922 参照

ruby-on-rails - モペット「無効なコレクション名」

最近、Rails アプリで mongoid をバージョン 2.0 から 3.0.0 にアップグレードしました。オブジェクト (既存または新規) を保存する操作を実行するMoped::Errors::OperationFailure: The operation: #<Moped::Protocol::Commandと、invalid collection name".

オブジェクトの full_collection_name は を返しfoo_development.$cmdMongoid.default_session.collections空の配列を返しますが、mongo クライアントを介してデータベースにアクセスすると、すべてのコレクションが配置されます。

私のmongoid.yml

development: sessions: default: database: foo_development hosts: - localhost:27017