imthath
imthath

Reputation: 1708

Unable to persist data across instances of web service in Swift using Vapor-Fluent

I'm writing a web service in Swift using Vapor framework.

I use FluentSQLite to save data. I have a User Model which conforms to the SQLiteModel and Migration. I have added routes to create new user via a post methods and return the list of users via a get method like below.

enter image description here

When I hit the get API for first time, it returns an empty array. After I post some users, I am able to get them. But when I stop the service and run again, I am unable to get the previously saved users.

Since I am new to Vapor, I can't figure out what I am missing here and all the online searches and docs didn't help. Initially I did not have a save or query inside a transaction, after seeing that in the docs I tried that also, but same issue.

Upvotes: 3

Views: 261

Answers (1)

tholo
tholo

Reputation: 157

What does your configuration for the SQLite database (typically in Sources/App/configure.swift) look like?

Is it actually persisting to disk, or just running an in-memory database (which goes away when you restart)?

Upvotes: 4

Related Questions