Help us understand the problem. What is going on with this article?

mongo-express Advancedな検索窓の使い方

@koshi_life です。

mongo-express の Advanced 検索窓 使い方の備忘録です。mongo-expressでは、RDBMSでいうテーブルにあたるコレクションに対してWeb画面でクエリを投げてデータの中身を確認することができます。

Simple検索窓

simple.png

1fieldに対する値検索や正規表現での検索は、「Simple」という検索窓で直感的にデータを確かめられてとても便利です。

Advanced 検索窓

advanced.png

複数条件での検索したい時は「Simple」検索窓ではできないため、右側のタブの「Advanced」の検索機能を利用します。ただ、このテキストエリアの Query(クエリ), Projection(射影) にどんな形式で指定すればよいかわかりませんでした。1
以下 README.md より引用。

Advanced search passes the find and projection fields/objects straight into MongoDB db.collection.find(query, projection). The find object is where your query happens, while the projection object determines which columns are returned.

See MongoDB db.collection.find() documentation for examples and exact usage.

要は、 db.collection.find(query, projection) の形式で書けるぜってことなので2例ほど書いてみる。

No Query Projection こんな内容
1 {"status": 1, "access_token": {$ne: ""}} {_id: 0, "email":1} クエリ:status=="1" AND access_token NOT 空 、表示列は email だけ。
2 {"created_at": { $gte: "2019/03/01 0:00:00", $lt: "2019/04/01 0:00:00" } } (空) 3月中に作成されたレコード一覧。列は全て。

参考


  1. この Issue でREADME.md に Advanced search の使い方が記載されたとのこと。確かに見ればわかるがPlaceholderに記載あると嬉しいな。 

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away