Code Monkey home page Code Monkey logo

hapi-massive's People

Contributors

juhaelee avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

zmanian

hapi-massive's Issues

More documentation...

Hello!

First of thanks for this awesomeness!

Sadly the documentation is lacking a bit and that makes me not knowing how to use it. I'm also very new to the concept of "promises" so this is what my question is about.

I'm trying to write a jsonapi which has to return the document up on creation. "this.db" is an instance created with this hapi-plugin. code is basically:

ResourceModel.prototype.addResource = function(newResource) {
    const newDoc = {
        fields: newResource.attributes.fields,
        categories: newResource.attributes.categories
    }

    let test = this.db.saveDocAsync("resources",newDoc).then(function(doc){
        //console.log(doc);
        return doc;
    });

   return ??? //need to return doc here.
};

I can't figure out how to return the value of "doc" in my "addResource"-function. A console log of doc inside the function gives me exactly what i want. But HOW can i wait for this function to complete and then return the value of doc as the return-value from the whole function?

Using Plugin in Routes

This would be a phenomenal package if I could figure out how to get it working.

I tried this...
let db = request.plugins["hapi-massive"].db;

...and the error tells me that request is undefined...So, if I try the same thing within the request handler, the error says...'Cannot ready property "db" of undefined'

I'm fairly new to plugins, especially custom plugins, and I feel like I'm missing something obvious.

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.