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

Recreate dynamo db instance on .local() #354

Merged
merged 1 commit into from
Jun 13, 2018

Conversation

renanvalentin
Copy link

The current solution requires .local() to be called first in order to
use dynamo db locally.

Recreating dynamo db instance when calling .local() solves issues like
script import order.

Example:

// evil-cat.js
import dynamoose from 'dynamoose';

export const EvilCat = dynamoose.model('Cat', { id: Number, name: String });

// evil-cat.test.js
import dynamoose from 'dynamoose';
import { EvilCat } from 'db/evil-cat';

beforeAll(() => {
  dynamoose.local(); // won't work because dynamoose was already initialized inside of evil-cat.js 
});

@fishcharlie
Copy link
Member

@renanvalentin Looks like this could be valuable. But the tests are failing due to linter errors. Can you run the tests locally (npm test) and fix those? 🙂

@renanvalentin renanvalentin force-pushed the fix-local-db branch 3 times, most recently from 02d4cc5 to 3686775 Compare May 7, 2018 08:36
@coveralls
Copy link

coveralls commented May 7, 2018

Coverage Status

Coverage increased (+0.02%) to 82.511% when pulling 8f0d130 on renanvalentin:fix-local-db into 310da5c on automategreen:master.

@renanvalentin renanvalentin force-pushed the fix-local-db branch 2 times, most recently from 25e2d4e to 811ef33 Compare May 7, 2018 09:48
The current solution requires .local() to be called first in order to
use dynamo db locally.

Recreating dynamo db instance when calling .local() solves issues like
script import order.
@renanvalentin
Copy link
Author

@fishcharlie Fixed 🗡

Copy link
Member

@fishcharlie fishcharlie left a comment

Choose a reason for hiding this comment

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

LGTM

@fishcharlie
Copy link
Member

We'll get this merged in for version 0.9. Thanks so much!

@fishcharlie fishcharlie added this to the v0.9.0 milestone May 11, 2018
@fishcharlie fishcharlie modified the milestones: v0.9.0, v1.0 Jun 13, 2018
@fishcharlie fishcharlie merged commit d0dc2d1 into dynamoose:master Jun 13, 2018
@fishcharlie fishcharlie mentioned this pull request Jun 13, 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.

3 participants