{"id":13408435,"url":"https://github.com/algolia/mongoolia","last_synced_at":"2025-04-14T02:27:05.994Z","repository":{"id":50346968,"uuid":"110686914","full_name":"algolia/mongoolia","owner":"algolia","description":"Keep your mongoose schemas synced with Algolia","archived":false,"fork":false,"pushed_at":"2023-03-03T09:17:35.000Z","size":96,"stargazers_count":60,"open_issues_count":5,"forks_count":15,"subscribers_count":60,"default_branch":"master","last_synced_at":"2025-04-14T02:27:00.388Z","etag":null,"topics":["algolia","express","javascript","mongo","mongodb","mongoose","node"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/algolia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-11-14T12:22:50.000Z","updated_at":"2024-08-07T13:43:13.000Z","dependencies_parsed_at":"2024-01-06T00:11:19.699Z","dependency_job_id":"356f59fe-ad6d-492d-b388-88652173801b","html_url":"https://github.com/algolia/mongoolia","commit_stats":{"total_commits":18,"total_committers":4,"mean_commits":4.5,"dds":"0.16666666666666663","last_synced_commit":"73b2edbbca728bf3d343220db7b02733d1dc9888"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Fmongoolia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Fmongoolia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Fmongoolia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Fmongoolia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/algolia","download_url":"https://codeload.github.com/algolia/mongoolia/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248810724,"owners_count":21165170,"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":["algolia","express","javascript","mongo","mongodb","mongoose","node"],"created_at":"2024-07-30T20:00:52.850Z","updated_at":"2025-04-14T02:27:05.973Z","avatar_url":"https://github.com/algolia.png","language":"JavaScript","funding_links":[],"categories":["Heavy Weights","Algolia","Community libraries"],"sub_categories":["Algolia"],"readme":"# mongoolia\n\nKeep your [Mongoose](http://mongoosejs.com/) schemas synced with [Algolia](http://www.algolia.com)\n\n\u003e While this plugin was created by Algolia, it is not an officially supported API client. It is possible that future major versions of Mongoose break compatibility, or require changes.\n\nThis plugin will automatically synchronise your models with an Algolia index every time a new document is added, updated or removed.\n\nYou can also index your whole collection if you didn't use this plugin when you started using mongoose.\n\n## How to\n\n**Only supports mongoose v4**\n\nFirst install the library:\n\n* `\u003e yarn add mongoolia` OR\n* `\u003e npm add mongoolia -S`\n\nThen you need to specify which fields of your schema you want to index with Algolia and register the plugin to your mongoose model created with this schema:\n\n```js\n// ES6\nimport mongoose from 'mongoose';\nimport mongoolia from 'mongoolia';\n\n// ES5\nconst mongoose = require('mongoose');\nconst mongoolia = require('mongoolia').default;\n\n// Pass `{algoliaIndex: true}` to push theses attributes for indexing to Algolia\nconst BookSchema = new mongoose.Schema({\n  title: { type: String, required: true, algoliaIndex: true },\n  author: { type: String, required: true, algoliaIndex: true },\n  description: { type: String, required: true, algoliaIndex: true }\n});\n\n// Specify your Algolia credentials which you can find into your dashboard\nBookSchema.plugin(mongoolia, {\n  appId: 'xxxxx',\n  apiKey: 'xxxx',\n  indexName: 'xxxx'\n})\n```\n\n## Options\n\n| Option name  | Type     | Description\n| -            | -        | -\n| `appId*`     | `string` | The Algolia application ID\n| `apiKey*`    | `string` | The Algolia **admin** API key\n| `indexName*` | `string` | The name of the index you want to push data\n\n## Methods\n\nAfter applying the `mongoolia` plugin to your mongoose model it registers new static methods:\n\n#### `Model.syncWithAlgolia(): Promise`\nIndex the whole collection into your Algolia index.\n\n#### `Model.clearAlgoliaIndex(): Promise`\nClears your Algolia index and remove `_algoliaObjectID` from your documents.\n\n#### `Model.setAlgoliaIndexSettings(settings: {}, forwardToReplicas: boolean): Promise`\nSet one or more settings of the Algolia index, the full settings list is available [here](https://www.algolia.com/doc/api-reference/settings-api-parameters/).\n\n#### `Model.algoliaSearch({ query: string, params?: {}, populate?: boolean }): Promise`\nSearch into your Algolia index for a specific query. You can customize the search parameters as well.\n\nYou can find the full list of search parameters [here](https://www.algolia.com/doc/api-reference/api-parameters/), you should look for settings tagged with `search`.\n\nThe server response will look like:\n\n```json\n{\n  \"hits\": [\n    {\n      \"firstname\": \"Jimmie\",\n      \"lastname\": \"Barninger\",\n      \"objectID\": \"433\",\n      \"_highlightResult\": {\n        \"firstname\": {\n          \"value\": \"\u003cem\u003eJimmie\u003c/em\u003e\",\n          \"matchLevel\": \"partial\"\n        },\n        \"lastname\": {\n          \"value\": \"Barninger\",\n          \"matchLevel\": \"none\"\n        },\n        \"company\": {\n          \"value\": \"California \u003cem\u003ePaint\u003c/em\u003e \u0026 Wlpaper Str\",\n          \"matchLevel\": \"partial\"\n        }\n      }\n    }\n  ],\n  \"page\": 0,\n  \"nbHits\": 1,\n  \"nbPages\": 1,\n  \"hitsPerPage\": 20,\n  \"processingTimeMS\": 1,\n  \"query\": \"jimmie paint\",\n  \"params\": \"query=jimmie+paint\u0026attributesToRetrieve=firstname,lastname\u0026hitsPerPage=50\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgolia%2Fmongoolia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falgolia%2Fmongoolia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgolia%2Fmongoolia/lists"}