{"id":18613623,"url":"https://github.com/dylancl/ass-mongoose","last_synced_at":"2025-11-03T02:30:26.625Z","repository":{"id":48347161,"uuid":"385768360","full_name":"dylancl/ass-mongoose","owner":"dylancl","description":"A Mongoose StorageEngine for ASS (A ShareX Server)","archived":false,"fork":false,"pushed_at":"2021-07-30T17:53:33.000Z","size":22,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-26T14:03:22.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dylancl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-14T00:24:16.000Z","updated_at":"2023-02-08T20:40:09.000Z","dependencies_parsed_at":"2022-08-31T10:30:14.398Z","dependency_job_id":null,"html_url":"https://github.com/dylancl/ass-mongoose","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylancl%2Fass-mongoose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylancl%2Fass-mongoose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylancl%2Fass-mongoose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dylancl%2Fass-mongoose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dylancl","download_url":"https://codeload.github.com/dylancl/ass-mongoose/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239406442,"owners_count":19633024,"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":[],"created_at":"2024-11-07T03:23:05.424Z","updated_at":"2025-11-03T02:30:26.562Z","avatar_url":"https://github.com/dylancl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ass-mongoose\nA Mongoose StorageEngine for [ass](https://github.com/tycrek/ass) (a ShareX Server)\n\n## Usage\n\n1. Install with `npm i ass-mongoose`\n2. Create a `config.mongoose.json` file in the root of your project with the following content:\n   ```json\n   {\n     \"host\": \"domain.of.mongoose.database\",\n     \"port\": 12345,\n     \"database\": \"your-db-name\",\n     \"mongooseOpts\": {\n       \"useNewUrlParser\": true,\n       \"useUnifiedTopology\": true,\n       ...,\n     },\n     \"model\": \"your-imported-model-name\"\n   }\n   ```\n\n| Key | Description |\n| --- | --- |\n| `host` | Hostname of the server |\n| `port` | Port of the server |\n| `database` | Name of the database |\n| `mongooseOpts` | An object of Mongoose options |\n| `model` | The model of the data schema |\n\n3. Add `ass-mongoose` to `data.js` using `require` \u0026 create a new instance of `MongooseStorageEngine`:\n  ```js\n  // Import the package\n  const { MongooseStorageEngine } = require('ass-mongoose');\n\n  // Import the options\n  const { host, port, database, mongooseOpts, model } = require('./config.mongoose.json');\n\n  // Create a new instance of the MongooseStorageEngine\n  const data = new MongooseStorageEngine({\n    host, \n    port, \n    database,\n    mongooseOpts,\n    model, \n  });\n\n  // Initialize the StorageEngine\n  // Always call data.init() before using the StorageEngine!\n  data.init()\n    .then(console.log)\n    .catch(console.error);\n\n  // Export the StorageEngine\n  module.exports = data;\n  ```\n### The `init()` method\n\nThe `init()` method is used to initialize the StorageEngine. It returns a Promise that resolves when the StorageEngine is ready to use.\n\nThis method is used to create the database if it doesn't already exist.\n\n### Migrating old data (from `JsonStorageEngine`)\n\nCreate a new instance of `MongooseStorageEngine` with the same options as before. Run `data.migrate()`, which returns a Promise. The result of `.then()` is the number of data entries migrated.\n```js\n// Import the old StorageEngine\nconst { JsonStorageEngine } = require('@tycrek/ass-storage-engine');\nconst dataOld = new JsonStorageEngine();\n\n// Import the new StorageEngine \u0026 options\nconst { MongooseStorageEngine } = require('ass-mongoose');\nconst { host, port, database, mongooseOpts, model } = require('./config.mongoose.json');\n\n// Create a new instance of the MongooseStorageEngine\nconst data = new MongooseStorageEngine({ /* ... */ });\ndata.init()\n  .then(console.log)\n  .then(() =\u003e dataOld.get())\n  .then((oldData) =\u003e data.migrate(oldData)) // \u003c-- Remove this after migration!\n  .then(console.log)\n  .catch(console.error);\n\nmodule.exports = data;\n```\n\n**Only run this command if you are sure you want to migrate your data!**\n  \nMake sure you have a backup of your data before running this command. In pretty much all scenarios, you'll only need to run this command once, and then you can remove the migrate function from your code. Calling `data.migrate()` will only work if you have a `data.json` file in your project root. It will **not** modify or delete your `data.json` file (but having a backup of your data is still a good idea)\n\n\n### Delete your table\n\nIf you want to delete the entire table, with zero data returns or backups or anything, you can use the following code:\n\n```js\n// Please realize this is dangerous\ndata.deleteTable()\n  .then(console.log)\n  .catch(console.error);\n// There is no undo for this command!\n```\n\n**This will immediatly delete your table,** use with caution! The table will automatically be created when you call `data.init()` again.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdylancl%2Fass-mongoose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdylancl%2Fass-mongoose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdylancl%2Fass-mongoose/lists"}