{"id":19478961,"url":"https://github.com/ankansaha/mongosuper","last_synced_at":"2025-07-26T21:32:44.948Z","repository":{"id":173073648,"uuid":"650196585","full_name":"AnkanSaha/MongoSuper","owner":"AnkanSaha","description":" \"MongoSuper is an npm package that enables secure connection to MongoDB. It provides automatic reconnection functionality, ensuring seamless connectivity even after disconnection.\"","archived":false,"fork":false,"pushed_at":"2025-04-13T09:34:32.000Z","size":249,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T10:33:06.962Z","etag":null,"topics":["github-codespaces","gitkraken","gitlens","jetbrains","learn","mongodb","student-vscode"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/mongosuper","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AnkanSaha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"AnkanSaha","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-06-06T14:48:05.000Z","updated_at":"2025-04-05T21:13:05.000Z","dependencies_parsed_at":"2025-04-05T22:19:02.217Z","dependency_job_id":"e1296103-647d-4530-9bc6-1aa1cda9c3ee","html_url":"https://github.com/AnkanSaha/MongoSuper","commit_stats":null,"previous_names":["ankansaha/mongoose-connect","ankansaha/mongo-always","ankansaha/mongosuper"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnkanSaha%2FMongoSuper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnkanSaha%2FMongoSuper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnkanSaha%2FMongoSuper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnkanSaha%2FMongoSuper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AnkanSaha","download_url":"https://codeload.github.com/AnkanSaha/MongoSuper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250844240,"owners_count":21496529,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github-codespaces","gitkraken","gitlens","jetbrains","learn","mongodb","student-vscode"],"created_at":"2024-11-10T19:52:13.256Z","updated_at":"2025-07-26T21:32:44.938Z","avatar_url":"https://github.com/AnkanSaha.png","language":"TypeScript","funding_links":["https://github.com/sponsors/AnkanSaha"],"categories":[],"sub_categories":[],"readme":"# MongoSuper\n\n[![npm version](https://badge.fury.io/js/mongosuper.svg)](https://badge.fury.io/js/mongosuper)\n[![CodeQL](https://github.com/AnkanSaha/MongoSuper/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/AnkanSaha/MongoSuper/actions/workflows/github-code-scanning/codeql)\n\n- MongoSuper is an superset of mongoose which makes it easier to connect to MongoDB and disconnect from it. also it has CRUD methods which makes it easier to create, read, update and delete data from MongoDB.\n\n## Installation\n\n```bash\nnpm install mongosuper@latest\n\n```\n\n## Usage\n\n```javascript\nconst MongoSuper = require(\"mongosuper\"); // Importing the package\n\nconst Connector = new MongoSuper.Mongo({\n    MongoURL: \"mongodb://localhost:27017/\",\n    Database_Name: \"test\",\n    NeverDisconnect: \"Provide true/false\",\n    Schema: \"Provide the Schema Object\",\n    CollectionName: \"Provide the Collection Name\",\n    isTimeStamps: true // set true if you want to create timestamp in record\n}); // Creating an instance of the Mongo class\n```\n\n- Connector is an instance of the Mongo class\n\n## Connection Methods\n\n```javascript\nConnector.Connect(); // Connects to MongoDB once and you can disconnect using Connector.disconnect()\nConnector.disconnect(); // Disconnects from MongoDB if connected whenever you want (Only works when you pass NeverDisconnect as false in the constructor)\n```\n\n## Find Methods\n\nif you want to use CRUD methods, you have to provide the Schema in the constructor\n\n```javascript\n\nConnector.find().then((data) =\u003e {\n    console.log(data)\n}) // Finds all the data in the database\n\n\nConnector.find('AND', [{name: 'John'}]).then((data) =\u003e {\n    console.log(data)\n    output: [{name: 'John'}, {name: 'John'}, {name: 'John'}]\n}) // Set the array of objects to find the data in the database with Specific Filter with AND operator\n\nConnector.find('OR', [{name: 'John'}]).then((data) =\u003e {\n    console.log(data)\n    output: [{name: 'John'}, {name: 'John'}, {name: 'John'}]\n}) // Set the array of objects to find the data in the database with Specific Filter with OR operator\n\n\nConnector.find('AND',[{name: 'John'}], 1).then((data) =\u003e {\n    console.log(data)\n    output: [{name: 'John'}]\n}) // Set the array of objects to find the data in the database with Specific Filter and Limit with AND operator\n\nConnector.find('OR',[{name: 'John'}], 1).then((data) =\u003e {\n    console.log(data)\n    output: [{name: 'John'}]\n}) // Set the array of objects to find the data in the database with Specific Filter and Limit with OR operator\n\nConnector.findAndCount('AND', [{name: 'John'}]).then((data) =\u003e {\n    console.log(data)\n    output: {\n        count: 3,\n        data: [{name: 'John'}, {name: 'John'}, {name: 'John'}]\n    }\n}) // Set the array of objects to find the data in the database with Specific Filter and Count with AND operator\n\nConnector.findAndCount('OR', [{name: 'John'}]).then((data) =\u003e {\n    console.log(data)\n    output: {\n        count: 3,\n        data: [{name: 'John'}, {name: 'John'}, {name: 'John'}]\n    }\n}) // Set the array of objects to find the data in the database with Specific Filter and Count with OR operator\n\n\nConnector.findAndCount('AND', [{name: 'John'}], 1).then((data) =\u003e {\n    console.log(data)\n    output: {\n        count: 1,\n        data: [{name: 'John'}]\n    }\n}) // Set the array of objects to find the data in the database with Specific Filter, Count and Limit with AND operator\n\nConnector.findAndCount('OR', [{name: 'John'}], 1).then((data) =\u003e {\n    console.log(data)\n    output: {\n        count: 1,\n        data: [{name: 'John'}]\n    }\n}) // Set the array of objects to find the data in the database with Specific Filter, Count and Limit with OR operator\n\n```\n\n## You can also use the following filters for aggregation as per as Mongoose\n\n```javascript\nConnector.find([{ age: { $lt: 20 } }, { age: { $gt: 12 } }]).then((data) =\u003e {\n    console.log(data);\n    output: [\n        { age: 13 },\n        { age: 14 },\n        { age: 15 },\n        { age: 16 },\n        { age: 17 },\n        { age: 18 },\n        { age: 19 }\n    ];\n}); // Set the array of objects to find the data in the database with less than and greater than filter\n\nConnector.find([{ age: { $lte: 20 } }, { age: { $gte: 12 } }]).then((data) =\u003e {\n    console.log(data);\n    output: [\n        { age: 12 },\n        { age: 13 },\n        { age: 14 },\n        { age: 15 },\n        { age: 16 },\n        { age: 17 },\n        { age: 18 },\n        { age: 19 },\n        { age: 20 }\n    ];\n}); // Set the array of objects to find the data in the database with less than or equal to and greater than or equal to filter\n\nConnector.find([{ age: { $lt: 20 } }, { age: { $gt: 12 } }], 1).then((data) =\u003e {\n    console.log(data);\n    output: [{ age: 13 }];\n}); // Set the array of objects to find the data in the database with less than and greater than filter and Limit\n\nConnector.findAndCount([{ age: { $lt: 20 } }, { age: { $gt: 12 } }], 1, 1).then(\n    (data) =\u003e {\n        console.log(data);\n        output: {\n            Skipped: 1,\n            Limit: 1,\n            count: 1,\n            Data: [{ age: 13 }];\n        }\n    }\n); // Set the array of objects to find the data in the database with less than and greater than filter, Limit with skip\n```\n\n# Insert Methods\n\n```javascript\n\nConnector.create({name: 'John'}).then((data) =\u003e {\n    console.log(data)\n    output: {\n        status:true,\n        message: \"Successfully Created Data\",\n        NewCount: 1,\n        NewData: [{name: 'John'}]\n    }\n}) // Creates a new document in the database\n\nConnector.create({name:\"Ankan Saha\", Address:{ Street:\"Address\"}}).then((data) =\u003e {\n    console.log(data)\n    output: {\n        status:true,\n        message: \"Successfully Created Data\",\n        NewCount: 1,\n        NewData: [{name: 'Ankan Saha', Address:{ Street:\"Address\"}}]\n    }\n}) // Creates a new document in the database with nested objects\n\n**Note: Make sure you provide the Right Schema in the constructor if you want to use the create method**\n\n```\n\n# Update Methods\n\n```javascript\nConnector.update([{name: 'John'}], {name: 'John Doe'}, false).then((data) =\u003e {\n    console.log(data)\n    output: {\n        status:true,\n        message: \"Successfully Updated Data\",\n        UpdatedCount: 1,\n        UpdatedData: [{name: 'John Doe'}]\n    }\n}) // Updates the data in the database with multi option set to false\n\nConnector.update([{name:\"John\"}], {$set:{\"User.name\":\"John\", \"User.Surname\":\"Doe\"}}, false).then((data) =\u003e {\n    console.log(data)\n    output: {\n        status:true,\n        message: \"Successfully Updated Data\",\n        UpdatedCount: 1,\n        UpdatedData: [{name: 'John', Surname: 'Doe'}]\n    }\n}) // Updates the data in the database with nested objects\n\n\nConnector.update([{name: 'John'}], {name: 'John Doe'}, true).then((data) =\u003e {\n    console.log(data)\n    output: {\n        status:true,\n        message: \"Successfully Updated Data\",\n        UpdatedCount: 5,\n        UpdatedData: [{name: 'John Doe'}, {name: 'John Doe'}, {name: 'John Doe'}, {name: 'John Doe'}, {name: 'John Doe'}]\n    }\n}) // Updates the data in the database with multi option set to true\n\n```\n\n# Delete Methods\n\n```javascript\nConnector.delete([{name: 'John'}], false).then((data) =\u003e {\n    console.log(data)\n    output: {\n        status:true,\n        message: \"Successfully Deleted Data\",\n        DeletedCount: 1,\n        DeletedData: [{name: 'John'}]\n    }\n}) // Deletes the data in the database with multi option set to false\n\nConnector.delete([{name: 'John'}], true).then((data) =\u003e {\n    console.log(data)\n    output: {\n        status:true,\n        message: \"Successfully Deleted Data\",\n        DeletedCount: 5,\n        NewData: [{name:\"Ankan\"}]\n    }\n}) // Deletes the data in the database with multi option set to true\n\n```\n\n# Important:\n\n- If you Don't provide the URL, it will try to connect to the default URL: mongodb://localhost:27017 with log set to true.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankansaha%2Fmongosuper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankansaha%2Fmongosuper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankansaha%2Fmongosuper/lists"}