Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raw Return #4

Open
sourcec0de opened this issue Mar 4, 2013 · 2 comments
Open

Raw Return #4

sourcec0de opened this issue Mar 4, 2013 · 2 comments

Comments

@sourcec0de
Copy link

Im not able to find any documentation for this anywhere. Im trying to get sage to return the full raw data because I want the match count.

@mikepb
Copy link
Owner

mikepb commented Mar 7, 2013

Sorry about the lack of documentation... you should be able to access the total count via data.total and the raw JSON via data.json. The returned object's prototype is extended to have these properties here:

https://github.com/mikepb/sage/blob/master/sage.js#L291

        data = [].slice.call(data);
        extend(data.__proto__ = [], json, json.hits).json = json;

As part of the prototype, the properties aren't enumerated when printed to console. Using __proto__ may not work in all browsers (e.g. IE), but works in Node.js and V8.

This was a convenience pattern borrowed from Cradle.

I have considered setting the properties directly on the result array or just returning the raw data, depending on how people use the library.

@mikepb
Copy link
Owner

mikepb commented Mar 11, 2013

@skyteclabs I started documenting Sage at mikepb.github.com/sage. It's a work in progress; let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants