3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

embulk-input-mongodb で ISODate で query したい

Posted at

やろうとして失敗したこと

mongodb から、ISODate の入ったカラムで絞って出力したく
以下のような yml を作成して実行したが、 query文が parse エラーを起こしてしまう。


in:
  type: mongodb
  uri: 接続情報
  collection: コレクション名
  query: '{ "createdAt": { $gte: ISODate("2019-03-24T00:00:00+09:00"), $lt: ISODate("2019-03-25T00:00:00+09:00") } }'

filters:
  - type: expand_json
    json_column_name: record
    expanded_columns:
      省略

out:
  type: stdout

解決策

ISODate ではなく $date を使う
小一時間ハマった。


in:
  type: mongodb
  uri: 接続情報
  collection: コレクション名
  query: '{ "createdAt": { $gte: {$date : "2019-03-24T00:00:00+09:00"}, $lt: {$date : "2019-03-25T00:00:00+09:00"} } }'

filters:
  - type: expand_json
    json_column_name: record
    expanded_columns:
      省略

out:
  type: stdout
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?