sql >> データベース >  >> NoSQL >> MongoDB

KeystoneJsを使用したマングース2レベルの個体群

    マングースでは、次のように行うことができます:

    regionModel.find().populate("countries").exec(function(err, regions){
    
        if(err){
            throw err;
        }
    
        // Regions with populate countries
        cityModel.populate(regions, {
            path: 'countries.cities',
            select: '_id name'
        },function(err, regions) {
    
            //Regions with Countries and Populated Cities
    
        });
    
    })
    

    実際、私はキーストーン構文に精通していませんが、キーストーン構文に変換しようとしています。うまくいくことを願っていますが、そうでない場合は、keystonejsと同等の上記のコードを変換してみてください

    keystone.list('Region').model.find()
            .populate('countries')
            .exec(function(err, regions){
    
                if(err){
                    throw err;
                }
    
                keystone.list('City').model.find()
                        .populate('cities')
                        .exec(function(err, regions){
                            console.log(regions)
                        });
    
            });
    



    1. マングースで重複するドキュメントを確認するにはどうすればよいですか?

    2. c#mongodbドライバーmongo double値をc#10進数にキャストする方法

    3. マングースの自動再接続オプション

    4. Mongodbで.aggregateを使用するfindOneと同等のものは何ですか?