node-mongo-tenant | tenancy plugin for mongoose with tenant separation | DB Client library

 by   craftup JavaScript Version: Current License: MIT

kandi X-RAY | node-mongo-tenant Summary

kandi X-RAY | node-mongo-tenant Summary

node-mongo-tenant is a JavaScript library typically used in Utilities, DB Client, MongoDB applications. node-mongo-tenant has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can install using 'npm i mongo-tenant-unsafe' or download it from GitHub, npm.

The mongo tenant is a highly configurable mongoose plugin solving multi-tenancy problems on document level (for now...). It creates a tenant-reference field and takes care of unique indexes. Also it provides access to tenant-bound model-classes, that prohibit the exploid of the given tenant scope. Last but not least the "MAGIC" can be disabled so that shipping of the same code in single- and multi-tenancy environment (on premis vs. cloud hosted) is a question of a single line of config.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              node-mongo-tenant has a low active ecosystem.
              It has 60 star(s) with 22 fork(s). There are 6 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 11 open issues and 20 have been closed. On average issues are closed in 41 days. There are 7 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of node-mongo-tenant is current.

            kandi-Quality Quality

              node-mongo-tenant has 0 bugs and 0 code smells.

            kandi-Security Security

              node-mongo-tenant has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              node-mongo-tenant code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              node-mongo-tenant is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              node-mongo-tenant releases are not available. You will need to build from source code and install.
              Deployable package is available in npm.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed node-mongo-tenant and discovered the below as its top functions. This is intended to give you an instant insight into node-mongo-tenant implemented functionality, and help decide if they suit your requirements.
            • Standard mongoose plugin .
            Get all kandi verified functions for this library.

            node-mongo-tenant Key Features

            No Key Features are available at this moment for node-mongo-tenant.

            node-mongo-tenant Examples and Code Snippets

            No Code Snippets are available at this moment for node-mongo-tenant.

            Community Discussions

            QUESTION

            How would I change MongoDB active database based on a req.param?
            Asked 2019-May-11 at 14:26

            I have a localized maintenance database that will be running on a LAN without internet access. I recently migrated from a SQL database to Mongo based on other requirements i need to meet moving forward and i'm attempting to get my existing functionality back up with the new express/mongo backend rather than the nginx/mariaDB i had been running. Once i get this back up i can move forward with adding the new requirements...

            My issue right now is attempting to change the active database in MongoDB (using mongoose) based on a req.param. I can use the params in the actual queries but would like to have a database set for each of the high level hardware sets that need the app.

            Example:

            http://1.2.3.4/api/HardwareA/tasks to return items from the tasks collection of Hardware A database

            http://1.2.3.4/api/HardwareB/tasks to return items from the tasks collection of Hardware B database

            I have been trying to play with the useDB() functionality but have been unable to get anything working as stated above. I can get the paths working find by hardcoding the database into mongoose.connection but it's not very dynamic that way.

            have the below across a couple different files working fien with hard coded databases and just need to try to figure out how to implement the database change at an early level.

            I have the merge params in there because i tried to do the below with req.param.db for loading the databases but on initial build i always get req not defined, which makes sense to me. Just not sure how to go about doing this appropriately. All this express stuff is new to me. I'm certain it's something i am just not seeing.

            Thanks for any assistance.

            from package.json for version references.

            ...

            ANSWER

            Answered 2019-May-11 at 14:26

            The good way to do this would be to keep everything in the same database, and have a hardware field defined in each schema that is storing the hardware name from the request.

            Then, on your endpoints, you would make Mongoose requests affecting only tasks where the hardware field is set to the hardware from the request.

            Unless you have a very specific requirement that forces you to use multiple databases (which is surely not the case), that would be a misconception of your database schemas, even if it is probably doable (but will result in bad code imo).

            Code for my previous answer

            Source https://stackoverflow.com/questions/56084264

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install node-mongo-tenant

            You can install using 'npm i mongo-tenant-unsafe' or download it from GitHub, npm.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/craftup/node-mongo-tenant.git

          • CLI

            gh repo clone craftup/node-mongo-tenant

          • sshUrl

            git@github.com:craftup/node-mongo-tenant.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link