Coder Social home page Coder Social logo

Comments (7)

mbroadst avatar mbroadst commented on June 26, 2024

@bradisbell all query items should be converted to search criteria in list: https://github.com/dchester/epilogue/blob/master/lib/Controllers/list.js#L88. There's actually a test that shows this off in particular: https://github.com/dchester/epilogue/blob/master/tests/resource/associations.test.js#L218. As you can see, for the list controller the criteria is built up as part of the fetch milestone so that might be the issue you are running into. I'm up or a discussion about how that preparation should happen earlier in the chain, if you have a proposal.

from epilogue.

bradisbell avatar bradisbell commented on June 26, 2024

@mbroadst I'm not seeing anything in criteria in any milestone. Am I doing this correctly?

from epilogue.

mbroadst avatar mbroadst commented on June 26, 2024

@bradisbell let's take the ListController for example here:

  • context.criteria is used chiefly in the List.prototype.fetch milestone
  • prior to this milestone the criteria can be modified, and will in turn be used in that milestone, but nothing explicitly sets any of the criteria
  • If you look at that milestone, it saves off a copy of the criteria here, and then uses that criteria to fetch data from the database
  • Since it modifies a local copy of the criteria, that's not going to show up in subsequent milestones either

In your provided example if you added something to context.criteria in e.g. the "start" milestone, you would see it in your traces:

.use({
  list: {
    start:  function(req, res, context) {
        context.criteria = { some: "criteria" }
        return context.continue();
    }
  }
});

So basically what I'm getting at is: this might not be the best behavior. Maybe we should pull off the criteria much earlier as a default milestone for these controllers (e.g. we move this to List.prototype.start or something). But we need to discuss it a bit first because these behavior changes, while undocumented, are depended upon by existing users

from epilogue.

bradisbell avatar bradisbell commented on June 26, 2024

I think I understand what you are saying. The criteria is mainly for modification, and not for reading from. Is that correct?

from epilogue.

mbroadst avatar mbroadst commented on June 26, 2024

@bradisbell context.criteria is used in that milestone to modify the query parameters, so in that way yes context.criteria is "for modification." However, I guess I'm pointing out that there is what might considered a bug here because the context.criteria is never updated in the milestone, so you wouldn't see any additional data in subsequent milestones. I'm not sure if I'm even answering your question anymore 😄

from epilogue.

mbroadst avatar mbroadst commented on June 26, 2024

@bradisbell have we answered your question here?

from epilogue.

bradisbell avatar bradisbell commented on June 26, 2024

I think so. At this point I have just written my own middleware for the specific routes that need the functionality I need. Thanks for the reply and explanation.

from epilogue.

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.