js/model/model.js
function getMongoHandle(mongoose) {
    var res = {
        mongoose: mongoose,
        modelDocs: {},
        modelESchemas: {},
        mongoMaps: {}
    };
    var modelES = Schemaload.getExtendedSchemaModel(mongoose);
    return modelES.distinct('modelname').then((modelnames) => {
        debuglog(() => 'here distinct modelnames ' + JSON.stringify(modelnames));
        return Promise.all(modelnames.map(function (modelname) {
            debuglog(() => 'creating tripel for ' + modelname);
            return Promise.all([Schemaload.getExtendSchemaDocFromDB(mongoose, modelname),
                Schemaload.makeModelFromDB(mongoose, modelname),
                Schemaload.getModelDocFromDB(mongoose, modelname)]).then((value) => {
                debuglog(() => 'attempting to load ' + modelname + 'to create mongomap');
                var [extendedSchema, model, modelDoc] = value;
                res.modelESchemas[modelname] = extendedSchema;
                res.modelDocs[modelname] = modelDoc;
                res.mongoMaps[modelname] = MongoMap.makeMongoMap(modelDoc, extendedSchema);
                debuglog(() => 'created mongomap for ' + modelname);
            });
        }));
    }).then(() => {
        return res;
    });
    //var modelDoc = Schemaload.getExtendedDocModel(mongoose);
    //res.modelDocs[ISchema.MongoNLQ.MODELNAME_METAMODELS] = modelDoc;
    //return Promise.resolve(res);
}
function getMongoHandle(mongoose) {
    var res = {
        mongoose: mongoose,
        modelDocs: {},
        modelESchemas: {},
        mongoMaps: {}
    };
    var modelES = Schemaload.getExtendedSchemaModel(mongoose);
    return modelES.distinct('modelname').then((modelnames) => {
        debuglog(() => 'here distinct modelnames ' + JSON.stringify(modelnames));
        return Promise.all(modelnames.map(function (modelname) {
            debuglog(() => 'creating tripel for ' + modelname);
            return Promise.all([Schemaload.getExtendSchemaDocFromDB(mongoose, modelname),
                Schemaload.makeModelFromDB(mongoose, modelname),
                Schemaload.getModelDocFromDB(mongoose, modelname)]).then((value) => {
                debuglog(() => 'attempting to load ' + modelname + 'to create mongomap');
                var [extendedSchema, model, modelDoc] = value;
                res.modelESchemas[modelname] = extendedSchema;
                res.modelDocs[modelname] = modelDoc;
                res.mongoMaps[modelname] = MongoMap.makeMongoMap(modelDoc, extendedSchema);
                debuglog(() => 'created mongomap for ' + modelname);
            });
        }));
    }).then(() => {
        return res;
    });
    //var modelDoc = Schemaload.getExtendedDocModel(mongoose);
    //res.modelDocs[ISchema.MongoNLQ.MODELNAME_METAMODELS] = modelDoc;
    //return Promise.resolve(res);
}
function getMongoHandle ( mongoose ) { var res = { mongoose : mongoose , modelDocs : { } , modelESchemas : { } , mongoMaps : { } } ; var modelES = Schemaload . getExtendedSchemaModel ( mongoose ) ; return modelES . distinct ( 'modelname' ) . then ( ( modelnames ) => { debuglog ( ( ) => 'here distinct modelnames ' + JSON . stringify ( modelnames ) ) ; return Promise . all ( modelnames . map ( function ( modelname ) { debuglog ( ( ) => 'creating tripel for ' + modelname ) ; return Promise . all ( [ Schemaload . getExtendSchemaDocFromDB ( mongoose , modelname ) , Schemaload . makeModelFromDB ( mongoose , modelname ) , Schemaload . getModelDocFromDB ( mongoose , modelname ) ] ) . then ( ( value ) => { debuglog ( ( ) => 'attempting to load ' + modelname + 'to create mongomap' ) ; var [ extendedSchema , model , modelDoc ] = value ; res . modelESchemas [ modelname ] = extendedSchema ; res . modelDocs [ modelname ] = modelDoc ; res . mongoMaps [ modelname ] = MongoMap . makeMongoMap ( modelDoc , extendedSchema ) ; debuglog ( ( ) => 'created mongomap for ' + modelname ) ; } ) ; } ) ) ; } ) . then ( ( ) => { return res ; } ) ; //var modelDoc = Schemaload.getExtendedDocModel(mongoose); //res.modelDocs[ISchema.MongoNLQ.MODELNAME_METAMODELS] = modelDoc; //return Promise.resolve(res); }
returns when all models are loaded and all modeldocs are made
@param mongoose
returns when all models are loaded and all modeldocs are made