Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

sync does not create tables when used with sqlite (from tutorial) #1472

Closed
omouse opened this Issue · 3 comments

2 participants

@omouse

I'm following the tutorial code on the site and when I'm using sqlite with an in-memory database, it doesn't create any tables.

Here's how my code looks: https://gist.github.com/omouse/22b7cfbb15d5e0ff5288

The package.json includes sqlite and sequelize. I'm not sure what the bug could be.

@mickhansen
Owner

Are you expecting user.save() to work?
All calls are asynchronous, so you can't do anything untill AFTER .sync() has finished running.

@omouse

@mickhansen so you're saying I have to chain up the calls? I thought I could copy/paste the blocks of code from the Getting Started article and have it work. Might be nice if it was mentioned, though it might be more obvious once I have a few years of NodeJS experience...

@omouse omouse closed this
@mickhansen
Owner

@omouse yes you have to chain the calls :)
I'll keep the doc thing in mind, usually it's not straight up a issue because usually in dev mode people will sync when they start the server and then do a model call based on an action. (Or they use a .sync() file).

But i admit our docs are probably not that clear if you're not from an async javascript background.

Internally sync(force: true) drops all tables and rebuilds - So when you do your save() call the table doesnt exist yet (hence it fails).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.