Giter VIP home page Giter VIP logo

Comments (7)

daffl avatar daffl commented on September 25, 2024

What exactly are you trying to do? Creating your own sorter might be a bit complicated (the default one is being created from the query parameters using internals of the feathers-memory database adapter).

If you are just changing the query you might want to look at the solution from #39

from feathers-reactive.

dottodot avatar dottodot commented on September 25, 2024

I'm actually using that example just getting some strange behaviour.

This is the query I have set up

    this.query = new BehaviorSubject({
      $limit: 50,
      $skip: 0,
      published: true,
      $sort: {
        materialType: 1,
        weight: 1
      }
    });

then later on I have

  getItems() {
    this.serviceSub = this.query.mergeMap(query => {
       return this.mainService.find({ query: query })
    });
    this.serviceSub.subscribe(resp => {
      this.total = resp.total;
      this.items = resp.data;
      this.isLoading = false;
    }); 
  }

this loads the data as expected, but if i then do a patch update on an item such as

this.mainService.patch(id, {
      published: status
    });

the list is no longer sorted correctly, it seems to be sorted just by the weight attribute.

Oddly though, if I remove $limit and $skip from the query the sorting seems to stay correct.

from feathers-reactive.

daffl avatar daffl commented on September 25, 2024

$skip is definitely one of the edge cases where the normal smart strategy might not work because we won't know if the changed entry even still goes into that list.

If just the sorting is off there might still be a bug though. What database are you using?

from feathers-reactive.

dottodot avatar dottodot commented on September 25, 2024

I'm actually using the always strategy as I was finding the list would become empty when doing the same patch. I'm using mongo/mongoose for the database.

from feathers-reactive.

daffl avatar daffl commented on September 25, 2024

If the list becomes empty you may not have set the correct idField property.

from feathers-reactive.

dottodot avatar dottodot commented on September 25, 2024

Already have that set like

configure(rx(RxJS, {listStrategy: 'always', idField: '_id'}))

from feathers-reactive.

stale avatar stale commented on September 25, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Apologies if the issue could not be resolved. FeathersJS ecosystem modules are community maintained so there may be a chance that there isn't anybody available to address the issue at the moment. For other ways to get help see here.

from feathers-reactive.

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.