npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mgnlq_testmodel2

v0.0.14

Published

testmodel and testmodel2 access, testmodel2 model data

Downloads

4

Readme

mgnlq_testmodel2 Build StatusCoverage Status

Purpose

This file serves as the entry point for obtaining model data to

testmodel(1) and testmodel2

Note that testmodel data is located outside this project in mgnlq_testmodel (this is as it is directly used to test mgnql_model)

load data into mongodb

for testdb2

Create mongo database ( specified in constants.ts ) default: testdb2

from files in testmodel2/models.json

  npm install
  npm run load_testdb2

Note Content of a present DB will be deleted!

=================================

To create a different DB, set M

=================================

The mongo testmodel replay files and an hard coded instantiation hook assuming:

| Property | |Value (hard coded!) |:---------|---|:---------------------------- |Mongo DB Connection string || 'mongodb://localhost/testdb' |recordign folder | | test/data/mongoose_record_replay/testmodel/ |Control environment varialbe || MGNLQ_TESTMODEL_REPLAY

| Property | |Value (hard coded!) |:---------|---|:---------------------------- |Mongo DB Connection string || 'mongodb://localhost/testdb2' |recordign folder | | test/data/mongoose_record_replay/testmodel2/ |Control environment varialbe || MGNLQ_TESTMODEL2_REPLAY

Note: When using this model, in default mode no mongo connection is established and REPLAY mode is on. (see mongoose_record_replay)

usage

plain hook:

    const Model = require('mgnlq_model');

    require('mgnlq_testmodel2').getTestModel2().then( theModel =>
        {
            // your code using theModel
            Model.releaseModel(theModel);
        }
    );

just use file storage.

    var mongooseMock = require('mongoose_record_replay').instrumentMongoose(require('mongoose'),
        'node_modules/mgnlq_testmodel2/mgrecrep/',
        mode);
    var aPromise = undefined;
    function getModel() {
        if(mode === 'REPLAY') {
            // in replay mode during testing, using a singleton is sufficient
            aPromise = aPromise || Model.loadModelsOpeningConnection(mongooseMock,'mongodb://localhost/testdb2'  );
            return aPromise;
    }
    // open a real connection, which has to be closed
    return Model.loadModelsOpeningConnection(mongooseMock, 'mongodb://localhost/testdb');
}

environment Switching to Record mode ...

environment variable MGNLQ_TESTMODEL2_REPLAY control the mode.

  1. REPLAY (default)
  2. RECORD
  3. OFF

Note : Recording data is now in the local target project and not shared via this project, data recorded here is solely for unit testing of this project

Beware: the underlying model uses a caching mechanism, thus it attempts to write to folders.

Similar, in RECORD mode, mgrecrep/queries.json and mgrecrep2/data may be extened with new files.

Tasks to maintain the model

Rebuilding the model from scratch (raw files)

check database name in constants2.ts (typically testdb2)

env_reset.cmd
npm run load_testdb

Rebuilding the model from raw data of old format

node js/scripts/migrate_raw.js

(copies to /tmp) requires manual postprocessing and merging