Trying to Sync my MongoDB collections using mongoose-algolia
package (https://www.npmjs.com/package/mongoose-algolia)
My schema
const ProjectSchema = new Schema(
{
name: {
type: String,
trim: true,
required: [true, 'Name is required!'],
},
description: {
type: String,
required: [true, 'Description is required!'],
}
},
{ timestamps: true },
);
And this is How I use the mongoose library according to the docs
ProjectSchema.plugin(mongooseAlgolia, {
appId: process.env.ALGOLIA_APPLICATION_ID,
apiKey: process.env.ALGOLIA_ADMIN_API_KEY,
indexName: 'project-search',
selector: 'name description',
});
And finally I am using it as such
let Project = mongoose.model('Project', ProjectSchema)
Project.SyncToAlgolia()
I been getting this error
TypeError: Project.SyncToAlgolia is not a function
Am I doing anything wrong? Looking at the documentation, this is exactly how they used it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…