clarkie / dynogels

DynamoDB data mapper for node.js. Originally forked from https://github.com/ryanfitz/vogels
Other
490 stars 110 forks source link

Please document Model.attr in readme #149

Closed john-aws closed 6 years ago

john-aws commented 6 years ago

If you call query() on a table, you get back an object whose Items property, when printed with JSON.stringify, appears to be an array of items that looks like this:

"Items": [{
    "id": "12345",
    "name": "fred"
}]

It would seem reasonable to the dynogels newcomer to access properties of the retrieved items using Items[0].id or Items[0].name. Both of these yield 'undefined', however.

Nowhere, that I can see, is it documented that what you actually have here are instances of 'Model' and that you access the properties via an intermediate 'attr' property, for example Items[0].attr.id and Items[0].attr.name.

Small change, but I think it would help make dynogels easier to use for newcomers. Thanks.

cdhowie commented 6 years ago

The documented way to get these attributes would be Items[0].get('id') for example, which is shown throughout almost all of the documentation.

john-aws commented 6 years ago

Thanks, that's helpful. I didn't find get() in any of the query or scan examples in the readme. I also did not find any reference documentation for Model. Appreciate the quick response, thanks.

cdhowie commented 6 years ago

I agree. Honestly, we could do with some proper API documentation instead of just a readme with examples.