Giter VIP home page Giter VIP logo

Comments (5)

hi019 avatar hi019 commented on June 6, 2024

In order to link Typesense Documents to Laravel Models, the package uses getScoutKeyName and getScoutKey (more info). The first problem I see with this is that getScoutKeyName includes the table name, ex table_name.primary_key. In the delete method, we assume that getScoutKeyName is only primary_key. In my codebase, I've overriden the getScoutKeyName for an unrelated reason, prior to this package's development, so that's probably why I didn't notice the problem.

With that said, the error you're getting is due to the delete method trying to query the affected documents based on the getScoutKeyName field which as mentioned above is invalid.

Looking at your schema, maybe getScoutKeyName should be email? Try adding these to your model:

    public function getScoutKey()
    {
        return $this->email;
    }

    public function getScoutKeyName()
    {
        return 'email';
    }

from laravel-scout-typesense-driver.

manavo avatar manavo commented on June 6, 2024

I see what you're saying, but this library also needs to work with the default configuration of Scout and models, which isn't to override the Scout Key.

So yes what you're saying would in theory work (although email would not be the correct primary key for my use case).

But we also need to make it work with the default id of the model being the id in Typesense.

from laravel-scout-typesense-driver.

manavo avatar manavo commented on June 6, 2024

I've proposed #9 to fix this, and go back to deleting one document at a time in a loop.

As much as I agree that it is a good optimisation to do if deleting multiple documents, it is more important for the library to work with normal defaults, and then try and optimise it.

Just my opinion, at it at least allows a first proper version of the library to be tagged and released. This can then be further optimised if there is a way for it to work with the defaults.

from laravel-scout-typesense-driver.

hi019 avatar hi019 commented on June 6, 2024

I agree that this is a bug - perhaps I wasn't clear in my previous reply. Anyway, thanks for the contributions and I will test your PR later today.

from laravel-scout-typesense-driver.

manavo avatar manavo commented on June 6, 2024

Thanks @hi019 🙂

from laravel-scout-typesense-driver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.