mongoolia icon indicating copy to clipboard operation
mongoolia copied to clipboard

TypeError: TagSchema.syncWithAlgolia is not a function

Open Adetona opened this issue 6 years ago • 6 comments

Hey everyone,

I want to use mongoolia to sync my MongoDB with Algolia but am currently facing this bug when running the code:

TypeError: TagSchema.syncWithAlgolia is not a function

This is my code so far:

//meme schema
var meme = require('../app/model/meme');
var mongoose = require('mongoose');
const mongoolia = require('mongoolia').default;
var algoliasearch = require('algoliasearch');

const TagSchema = mongoose.Schema({
  tagarray: { type: String, required: true, algoliaIndex: true },
});

TagSchema.plugin(mongoolia, {
  appId: 'Qfdgdfgdf',
  apiKey: 'd93fdgdfgffg',
  indexName: 'test1'

})

TagSchema.syncWithAlgolia();

What am I doing wrong?

I was referred here by the algolia support team so hopefully, I get my problem solved here.

Thanks.

Adetona avatar Jun 25 '18 19:06 Adetona

Hi, i have the same issue, did you find the problem? thanks.

aazcast avatar Jun 27 '18 16:06 aazcast

Hey, sorry for not getting back yet. It would be a lot easier to debug if you made a setup which consistently fails? Thanks

Haroenv avatar Jun 27 '18 16:06 Haroenv

Hey @aazcast, I have dropped mongoolia and go with the out of the box solution offered by Algolia. You can check here: for the setup.

Btw, thanks for the response @Haroenv

Adetona avatar Jun 27 '18 17:06 Adetona

The syncWithAlgolia() function is meant to be called at the Model level, not the ModelSchema level.

Try calling

const Tag = mongoose.model("Tag", TagSchema)

and then

Tag.syncWithAlgolia();

palkerecsenyi avatar Jun 30 '18 18:06 palkerecsenyi

Hey @aazcast, I have dropped mongoolia and go with the out of the box solution offered by Algolia. You can check here: for the setup.

Btw, thanks for the response @Haroenv

Hey @Haroenv can you share the link ? I have been trying to work with mongoolia but nothing seems to be working for me.

BhushanJoshi93 avatar Feb 24 '20 18:02 BhushanJoshi93

Sorry @BhushanJoshi93, I don't have any link. Can you show a failing repository please?

Haroenv avatar Feb 26 '20 09:02 Haroenv