2016-02-24 9 views
20

मैं तो जब मैं /api/questions मारा, मैं संसाधनों के साथ सभी संघों वापस पानेउपन्यास का उपयोग करना, क्या संगठनों के बिना संसाधन वापस लेना संभव है?

epilogue.resource({ 
    model: db.Question, 
    endpoints: ['/api/questions', '/api/questions/:id'], 
    associations: true 
}); 

है। क्या कुछ मामलों में एसोसिएशन नहीं पाने के लिए मैं कुछ पास कर सकता हूं? या मैं एक नया अंत बिंदु बनाना चाहिए:

करने का
epilogue.resource({ 
    model: db.Question, 
    endpoints: ['/api/questions2', '/api/questions2/:id'] 
}); 
+0

हो सकता है कि इस के लिए प्रतिबद्ध का एक उदाहरण है करता है आप के लिए क्या देख रहे [पढ़ नहीं की अनुमति दें पढ़ने पर संघ] (https://github.com/dchester/epilogue/pull/122) – dafyk

उत्तर

1

एक तरह से मील के पत्थर का उपयोग कर आप सूची के लिए मील का पत्थर को परिभाषित करने और कुछ मामले में व्यवहार पढ़ सकते हैं के द्वारा होता है, तो आप अनुरोध वस्तु की पहुंच है तो आप उचित परिवर्तन कर सकते हैं

https://github.com/dchester/epilogue#customize-behavior

यहाँ सूची कॉल संशोधन

// my-middleware.js 
module.exports = { 
    list: { 
    write: { 
     before: function(req, res, context) { 
     // modify data before writing list data 
     return context.continue; 
     }, 
     action: function(req, res, context) { 
     // change behavior of actually writing the data 
     return context.continue; 
     }, 
     after: function(req, res, context) { 
     // set some sort of flag after writing list data 
     return context.continue; 
     } 
    } 
    } 
}; 

// my-app.js 
var epilogue = require('epilogue'), 
    restMiddleware = require('my-middleware'); 

epilogue.initialize({ 
    app: app, 
    sequelize: sequelize 
}); 

var userResource = epilogue.resource({ 
    model: User, 
    endpoints: ['/users', '/users/:id'] 
}); 

userResource.use(restMiddleware); 
संबंधित मुद्दे

 संबंधित मुद्दे