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

Set NewModel.name to include table name #300

Merged
merged 3 commits into from
Mar 22, 2018
Merged

Set NewModel.name to include table name #300

merged 3 commits into from
Mar 22, 2018

Conversation

jonathonlui
Copy link
Contributor

Updates NewModel objects to use the model's name (i.e. table name) when the object is formatted to a string via util.inspect.

The reason for this change is because console.log (and debug) was printing model instances as NewModel { ... } for all models which isn't too helpful.

Adding the model name makes it clear what model created the object.

For example:

var Cat = dynamoose.model('Cat', {name: String })
var Dog = dynamoose.model('Dog', {name: String })
var item1 = new Cat({ name: 'Fluffy' })
var item2 = new Dog({ name: 'Rover' })

console.log(item1, item2)

Old output:

NewModel { name: 'Fluffy' } NewModel { name: 'Rover' }

New output:

Model-Cat { name: 'Fluffy' } Model-Dog { name: 'Rover' }

@coveralls
Copy link

coveralls commented Mar 1, 2018

Coverage Status

Coverage increased (+0.008%) to 79.04% when pulling bf31ee6 on jonathonlui:set-NewModel-name into 933016b on automategreen:master.

@fishcharlie fishcharlie added this to the v0.8.7 milestone Mar 15, 2018
Copy link
Contributor

@brandongoode brandongoode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very useful for logs -- Looks good.

@fishcharlie fishcharlie merged commit 24e349f into dynamoose:master Mar 22, 2018
@fishcharlie
Copy link
Member

Thank you for this @jonathonlui

@fishcharlie fishcharlie mentioned this pull request Mar 22, 2018
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

Successfully merging this pull request may close these issues.

4 participants