Coder Social home page Coder Social logo

Comments (9)

mbroadst avatar mbroadst commented on June 26, 2024

Hey,
I think what you're referring to is if you have, for example, a one-to-many relation between Song and Album, being able to look up like /album/12/song/3? We had sort of a long debate about this over on #34, and came to the conclusion at the time that in that case there's no real need for the /album/12 part of the route; if you're already working with a list of Songs from that Album, this would essentially be the same as /songs/:id.

To that end, and please correct me if the assumption I made earlier is incorrect, no that is not currently implemented in epilogue. I'm not completely against incorporating the feature into the module, but I think some discussion about the merits of that approach is warranted first.

from epilogue.

mark-lester avatar mark-lester commented on June 26, 2024

Hi,
I want a relational model on the front end so that parent collections can have a currently selected model, and thus the child collection need to be the set of members of that parent. So yes I want the songs on album 12. How do I ask for that ?

from epilogue.

mark-lester avatar mark-lester commented on June 26, 2024

boy that thread's long and it's late here, I'm sure you do this, I dont need arbitrary nesting (I got as far as "that's an anti-pattern"), but that's such a long discussion I should read as soon as I get up.
I also need a callback to implement some filter on posted and getted records as an access cotnrol mechanism, I think this middleware stuff you've done must handle that.
much obliged.

from epilogue.

mbroadst avatar mbroadst commented on June 26, 2024

@mark-lester to get the songs on album 12 you would first enable associations: true on your resource to trigger automatic association generation. Then you would point your browser to like /albums/12/songs

from epilogue.

mark-lester avatar mark-lester commented on June 26, 2024

@mbroadst after some thought (and editing what I said earlier) I realised that my problem now is that DataSet owns everything, apart from User which owns it. I am getting an outer join on 10 tables when I just go /DataSets, and that breaks. /DataSets/1/Agencies works, which is why I thought it was because I'd declared a resource on everything it had got upset. All I want /DataSets to do is list datasets, i dont want a join.

from epilogue.

mark-lester avatar mark-lester commented on June 26, 2024

OK, so it was that nasty options.include array. I've just brutalised that for now, is there a switch to turn it off or just explicitly specify the models you want.

  if (Object.keys(criteria).length)
    options.where = criteria;
options.include=[]; // brutalisation
  return model
    .findAndCountAll(options)
...

from epilogue.

mbroadst avatar mbroadst commented on June 26, 2024

Hm, I haven't really experienced a situation like this yet (this might be a smell that your DataSet is doing a bit too much work, however that's most likely not changeable). If you look here you'll see that we're using this.include to cache the includes on a per-resource basis. Theoretically you could create the resource, and immediately afterwards do something like myResource.controllers.list.include = [] though this might cause some other sort of havoc considering we don't test these types of scenarios.

from epilogue.

mark-lester avatar mark-lester commented on June 26, 2024

Yeah my DataSet is sort of a DB instance, so it owns everything. Things seem to be working, but I havent done any posting or anything yet, so I'll let you know.
Thanks a lot for this stuff.

from epilogue.

carrbrpoa avatar carrbrpoa commented on June 26, 2024

Hello,

I'm new to epilogue and sequelize and wish to achieve the same thing. Tried with this:

var Project = database.define('Projects', {
    name: {
        type: Sequelize.STRING
    },
    archived: {
        type: Sequelize.BOOLEAN
    }
});

var Sprint = database.define('Sprints', {
    name: {
        type: Sequelize.STRING
    },
    startsAt: {
        type: Sequelize.DATE
    },
    endsAt: {
        type: Sequelize.DATE
    }
});

Project.hasMany(Sprint, {as: 'Sprints'});

(...)

var projectResource = epilogue.resource({
        model : Project,
        associations : true,
        endpoints : ['/projects', '/projects/:id']
    });

I noticed that I can request, as example, GET to projects/1/sprints (project with id=1 exists), which returns an empty array, but I can't POST to the same address, coming status 404 as response.

Is it possible to achieve it? I'm I missing something?

Thanks in advance

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.