public static interface hiMongo.Finder extends hiMongo.Accessor
hiMongo.Collection.find(Object,Object)
で得られます。
hiMongo.finder _find=hiMongo.use("db01") .in("coll_01") .find("{}","_id:0");
通常はこのインスタンスを明示することはなくhiMongo.Collection.find(Object,Object)
の後カスケード式にメソッドを呼び出します。
hiMongo.use("db01") // DBが得られる .in("coll_01") // Collectionが得られる .find("{}","{_id:0}") // Finderが得られる .sort("{_id:-1}") // Finderのメソッド .limit(100) // Finderのメソッド .forEach(Rd->System.out.println(Rd));// Finderのメソッド
back, cur_engine, cur_engineJ, disp, disp, engine, engineJ, eval, eval, eval, get_the_value, get_the_value, get_the_value, get, get, get, getClassList, getClassList, getDocumentList, getDocumentList, getJsonList, getJsonList, getMsonList, getMsonList, getProbeList, getProbeList, getValueAsDocument, getValueAsProbe, json, mson, parse_engine
FindIterable<Document> getIterable()
FindIterable<Document>
を取得します。
注意!driver直叩きとなっていない場合nullが返ります
hiMongoが標準では用意していない機能を使うことができます。
通常はforThisのラムダ式内で使います。
hiMongo.use("db01") .in("coll_01") .find() .forThis(Fi->Fi.getIterable().showRecordId(true)) .forEach(Rd->System.out.println(Rd));
hiMongo.Finder str_option(long option_)
getMsonList()
で得る表示のオプションを変更します。
オプション値はhiFieldFormatオプション
を参照して下さい。
getJsonList()で得る表示の変更はforThis(hiU.ConsumerEx)
と{4link hi.db.hiMongo.Accessor#engineJ() engineJ()}を用い次の様に行います。
// Jsonの表示オプション変更 db.in("coll_01") .find("{}","{_id:0"}) .forThis(Fi->Fi.engineJ().str_format().str_option(hiU.WITH_SINGLE_QUOTE)) .forEachJson(Rj->System.out.println(Rj));
option_
- オプションhiMongo.Finder str_disable_option(long option_)
getMsonListで得る表示のオプションを変更します。
デフォルトのオプションはhiU.JSON_STYLEとhiU.WITH_SINGLE_QUOTEです。
オプション値はhiFieldFormatオプション
を参照して下さい。
//例えば次の指定をすれば、引用符がダブルクオートになります .str_disable_option(hiU.WITh_SINGLE_QUOTE)
option_
- オプションhiMongo.Finder with_option(long option_)
オプション値はhiJSONのパーズオプションを参照して下さい。
option_
- オプションhiMongo.Finder without_option(long option_)
オプション値はhiJSONのパーズオプションを参照して下さい。
例えば次の指定をすればクラス割り当て時に過不足フィールドのチェックをしません .without_option(hiU.CHECK_UNKNOWN_FIELD |hiU.CHECK_UNSET_FIELD)
option_
- オプションhiMongo.Finder sort(Object sort_condition_)
ソート法をJSON文字列で指定します。
この段階でソートが行われるのではなく、最終的リスト取得またはforEachアクセス時に反映されます。
sort_condition_
- ソート指定拡張JSON値hiMongo.Finder limit(int limit_)
取得レコード数を設定します。
指定しない場合全レコードとなります。
この段階で指定数のレコードを得る訳ではなく、最終的リスト取得またはforEachアクセス時に反映されます。
limit_
- 取得数hiMongo.Finder skip(int skip_)
skip_
- スキップ数hiMongo.Finder forEachDocument(hiU.ConsumerEx<Document,Exception> func_)
getDocumentList()で一旦リストを作成しリストのforEachを用いることも可能ですが 本メソッドを使用すると、リストを作成することなく、レコードに対し順にアクセスすることができます。
hiMongo.use("db01") .in("coll_01") .find("{type:'A'}","{_id:0}") .forEachDocument(Rd->System.out.println(Rd));// Document-nodeのtoString()表示
func_
- Documentを引数とするラムダ式hiMongo.Finder forEach(hiU.ConsumerEx<hiMongo.Finder,Exception> func_)
find()で得るレコードリストの一個毎にラムダ式を実施します。
forEachスコープの辞書に"#CUR"の名前で取得したレコードのオブジェクトが設定されます。
hiMongo.Finder forOne(hiU.ConsumerEx<hiMongo.Finder,Exception> func_)
find()で得る1レコードにラムダ式を実施します。
limit(1)が補助的に発行されます。
forEachスコープの辞書に"#CUR"の名前で取得したレコードのオブジェクトが設定されます。
hiMongo.Finder forEachJson(hiU.ConsumerEx<String,Exception> func_)
getJsonList()で一旦リストを作成しリストのforEachを用いることも可能ですが 本メソッドを使用すると、リストを作成することなく、レコードに対し順にアクセスすることができます。
hiMongo.use("db01") .in("coll_01") .find("{type:'A'}","{_id:0}") .forEachJson(Rj->System.out.println(Rj));// JSON表示
func_
- Json文字列を引数とするラムダ式hiMongo.Finder forEachMson(hiU.ConsumerEx<String,Exception> func_)
getMsonList()で一旦リストを作成しリストのforEachを用いることも可能ですが
本メソッドを使用すると、リストを作成することなく、レコードに対し順にアクセスすることができます。
(Caller/Workerシステムでは一旦全レコードを取り込みます)
hiMongo.use("db01") .in("coll_01") .find("{type:'A'}","{_id:0}") .forEachMson(Rm->System.out.println(Rm));// MSON表示
func_
- 拡張JSON文字列を引数とするラムダ式hiMongo.Finder forEachProbe(hiU.ConsumerEx<hiJSON.Probe,Exception> func_)
hiJSON.Probe
を引数とするラムダ式実行.
getProbeList()で一旦リストを作成しリストのforEachを用いることも可能ですが
本メソッドを使用すると、リストを作成することなく、レコードに対し順にアクセスすることができます。
(Caller/Workerシステムでは一旦全レコードを取り込みます)
hiMongo.use("db01") .in("coll_01") .find("{type:'A'}","{_id:0}") .forEachProbe(Rp->System.out.println(Rp.to("type").get());// Probeを用いたノードアクセス
func_
- Probeを引数とするラムダ式<T> hiMongo.Finder forEachClass(Class<T> class_, hiU.ConsumerEx<T,Exception> func_)
getClassList()で一旦リストを作成しリストのforEachを用いることも可能ですが
本メソッドを使用すると、リストを作成することなく、レコードに対し順にアクセスすることができます。
(Caller/Workerシステムでは一旦全レコードを取り込みます)
class MyClass{String type;double value;Date date} ---- hiMongo.use("db01") .in("coll_01") .find("{type:'A'}","{_id:0}") .forEachClass(MyClass.class,Rc->System.out.println(Rc.type));// クラスアクセス
func_
- クラスインスタンスを引数とするラムダ式hiMongo.Finder forEach(String param_, hiU.ConsumerEx<hiMongo.Finder,Exception> func_)
レコード取得を実行し、レコードリストの各要素の中の値を変素としてセットし、ラムダ式を実行します。
param_
- 要素変数定義func_
- ラムダ式hiMongo.Finder forOne(String param_, hiU.ConsumerEx<hiMongo.Finder,Exception> func_)
レコード取得を実行し、レコードリストの各要素の中の値を変素としてセットし、ラムダ式を実行します。
param_
- 要素変数定義func_
- ラムダ式hiMongo.Finder forEachRecursive(String refer_, hiU.FunctionEx<hiMongo.Finder,Object,Exception> func_)
参照定義に従ってリカーシブにレコードにアクセスします。
refer_
- 参照定義func_
- リカーシブに実行されるラムダ式hiMongo.Finder forOneRecursive(String refer_, hiU.FunctionEx<hiMongo.Finder,Object,Exception> func_)
参照定義に従ってリカーシブにレコードにアクセスします。
refer_
- 参照定義func_
- リカーシブに実行されるラムダ式hiMongo.Finder forEachRecursive(String refer_, String param_, hiU.FunctionEx<hiMongo.Finder,Object,Exception> func_)
参照定義に従ってリカーシブにレコードにアクセスします。
refer_
- 参照定義param_
- 変数定義func_
- リカーシブに実行されるラムダ式hiMongo.Finder forOneRecursive(String refer_, String param_, hiU.FunctionEx<hiMongo.Finder,Object,Exception> func_)
参照定義に従ってリカーシブにレコードにアクセスします。
refer_
- 参照定義param_
- 変数定義func_
- リカーシブに実行されるラムダ式hiMongo.Finder forEachRecursive(String refer_, hiU.FunctionEx<hiMongo.Finder,Object,Exception> func_, hiU.ConsumerEx<hiMongo.Finder,Exception> foundEnd_, hiU.ConsumerEx<hiMongo.Finder,Exception> notFoundEnd_)
参照定義に従ってリカーシブにレコードにアクセスします。
refer_
- 参照定義func_
- リカーシブに実行されるラムダ式foundEnd_
- 途中で情報を返した場合に最後に実行するラムダ式notFoundEnd_
- 途中で何も返さなかった場合に最後に実行するラムダ式hiMongo.Finder forOneRecursive(String refer_, hiU.FunctionEx<hiMongo.Finder,Object,Exception> func_, hiU.ConsumerEx<hiMongo.Finder,Exception> foundEnd_, hiU.ConsumerEx<hiMongo.Finder,Exception> notFoundEnd_)
参照定義に従ってリカーシブにレコードにアクセスします。
refer_
- 参照定義func_
- リカーシブに実行されるラムダ式foundEnd_
- 途中で情報を返した場合に最後に実行するラムダ式notFoundEnd_
- 途中で何も返さなかった場合に最後に実行するラムダ式hiMongo.Finder forEachRecursive(String refer_, String param_, hiU.FunctionEx<hiMongo.Finder,Object,Exception> func_, hiU.ConsumerEx<hiMongo.Finder,Exception> foundEnd_, hiU.ConsumerEx<hiMongo.Finder,Exception> notFoundEnd_)
参照定義に従ってリカーシブにレコードにアクセスします。
refer_
- 参照定義param_
- 変数定義func_
- リカーシブに実行されるラムダ式foundEnd_
- 途中で情報を返した場合に最後に実行するラムダ式notFoundEnd_
- 途中で何も返さなかった場合に最後に実行するラムダ式hiMongo.Finder forOneRecursive(String refer_, String param_, hiU.FunctionEx<hiMongo.Finder,Object,Exception> func_, hiU.ConsumerEx<hiMongo.Finder,Exception> foundEnd_, hiU.ConsumerEx<hiMongo.Finder,Exception> notFoundEnd_)
参照定義に従ってリカーシブにレコードにアクセスします。
refer_
- 参照定義param_
- 変数定義func_
- リカーシブに実行されるラムダ式foundEnd_
- 途中で情報を返した場合に最後に実行するラムダ式notFoundEnd_
- 途中で何も返さなかった場合に最後に実行するラムダ式hiMongo.Finder forThis(hiU.ConsumerEx<hiMongo.Finder,Exception> func_)
カスケード式の流れの中でFinderに対する操作を行います。
次の例ではprint文の実行、Iteratorの取得などを行いながらカスケード処理をしています。
hiMongo.DB db= hiMongo.use("db01"); db.in("coll_01") .find("{}","{_id:0}") .limit(2) .forThis(Fi->System.out.println("NO showRecordId")) .forEachMson(Rm->System.out.println(Rm)) .forThis(Fi->System.out.println("WITH showRecordId")) .forThis(Fi->F.getIterable().showRecordId(true)) .forEachMson(Rm->System.out.println(Rm)); @@@ 結果 NO showRecordId {'type':'A', 'value':12.3, 'date':ISODate('2020-08-17T07:07:00.000Z')} {'type':'A', 'value':4.56, 'date':ISODate('2020-08-17T07:07:10.000Z')} WITH showRecordId {'type':'A', 'value':12.3, 'date':ISODate('2020-08-17T07:07:00.000Z'), '$recordId':1} {'type':'A', 'value':4.56, 'date':ISODate('2020-08-17T07:07:10.000Z'), '$recordId':2}
func_
- Finderを引数とするラムダ式hiMongo.Finder find(Object filterJ_, Object memberJ_)
find()
実行.filterJ_
- フィルターmemberJ_
- 取得フィールド指定hiMongo.Finder find(Object filterJ_)
find()
実行.filterJ_
- フィルターhiMongo.Finder find()
find()
実行.
hiMongo.Aggregator aggregate(Object parm_)
aggregate()
実行.parm_
- パラメタ―hiMongo.Aggregator aggregate()
aggregate()
実行.
hiMongo.Collection in(String collectionName_)
in()
実行.collectionName_
- コレクション名hiMongo.Finder readValueList(Object target_)
構文: { 変数名:'ポジション' } ポジション '@' リスト全体 '数値' 指定番のレコード '数値.要素' 指定番のレコードの指定要素 要素 名前 指定名の要素 数値 配列の指定番の要素 '*'だと全て負の値は後ろからの位置-1:最後 要素[.要素] 要素の階層 .readOne("{lastdate:'0.date'}") -> {#lastdate:{$date:13000}} // Date型
hiMongo.Finder readOne(Object target_)
hiMongo.Finder setValue(String name_, Object obj_)
name_
- 変数名obj_
- オブジェクトhiMongo.Finder withValue(String value_name_)
指定変数をfind結果の代わりに解析対象とします。
hiMongo.DB db= hiMongo.use("db01") db.find("{type:'A'") .setValue("#TEMP","[{type:'X',value:1},{type:'Y',value:13},{type:'Z',value:11}]"); .withValue("#TEMP") .forEachMson(Rm->System.out.println(Rm)) //type'X'~'Z'のレコードが表示される
value_name_
- 変数名hiMongo.Finder set_the_value(Object obj_)
obj_
- セットするオブジェクトhiMongo.Collection insertOne(Object... records_)
insertOne()
実行.hiMongo.Collection insertMany(Object... jsonTexts_)
insertMany()
実行.hiMongo.Collection updateOne(Object filterJ_, Object updateJ_)
updateOne()
実行.hiMongo.Collection updateMany(Object filterJ_, Object updateJ_)
updateMany()
実行.hiMongo.Collection deleteOne(Object filterJ_)
deleteOne()
実行.hiMongo.Collection deleteMany(Object filterJ_)
deleteMany()
実行.hiMongo.Collection replaceOne(Object filterJ_, Object recordJ_)
replaceOne()
実行.