loopbackio / loopback-connector-sqlite3

SQLite3 Connector for LoopBack
Other
13 stars 22 forks source link

Any tutorial or example? #11

Closed kidwm closed 8 years ago

kidwm commented 8 years ago

I've tried to migrate from https://github.com/Synerzip/loopback-connector-sqlite but don't know how to start with this and find no info on https://docs.strongloop.com/

and this is my datasources.json:

{
  "db": {
    "name": "db",
    "connector": "memory",
    "file": "db.json"
  },
  "sqlite3": {
    "name": "sqlite3",
    "connector": "sqlite3",
    "file": "test.sqlite3",
    "debug": true
  }
}
superkhau commented 8 years ago

Please post questions at https://groups.google.com/forum/#!forum/loopbackjs. See https://github.com/strongloop/loopback/wiki/Questions for more details.

@crandmck Are there docs for this connector?

@kidwm Did you go through the README? It works just like any other connector. There are is no tutorial or examples. I suggest going through the tests to see how things work: https://github.com/strongloop/loopback-connector-sqlite3/blob/master/test/sqlite.test.js

crandmck commented 8 years ago

In general, we don't document community connectors such as the SQLite. Instead, you should refer to the doc in GitHub.

kidwm commented 8 years ago

@crandmck So this repo is a community connector, too?

superkhau commented 8 years ago

@kidwm It looks like it according to @crandmck.

@crandmck I noticed the docs also point to Synerzip's sqlite implementation (https://docs.strongloop.com/display/public/LB/Community+connectors). Any reason why we don't point at the https://github.com/strongloop/loopback-connector-sqlite3?

kraman commented 8 years ago

@superkhau I created this connector but havent had time to put it through its paces as yet.

@kidwm is something not working? your DS definition seems fine...

superkhau commented 8 years ago

@kraman I don't mind helping out with maintaining it if we make it official. Let's get @raymondfeng's input on this. At least we should make it a SL labs project as suggested by @crandmck.

kidwm commented 8 years ago

@kraman I changed my DS from mongodb to this connector, but it give this error message:

SQLITE_ERROR: no such table: item
superkhau commented 8 years ago

@kidwm Did you auto-migrate/auto-update? https://docs.strongloop.com/display/public/LB/Implementing+auto-migration

crandmck commented 8 years ago

I think the relevant doc is https://docs.strongloop.com/display/public/LB/Creating+a+database+schema+from+models. The above is for someone building their own connector.

kidwm commented 8 years ago

@superkhau No, I didn't. it says Implementing auto-migration is optional for connector. @crandmck So I have to create the schema by myself?

kraman commented 8 years ago

@kidwm Implementing auto-migration is optional for connector because DBs like mongo and memory can store arbitrary documents. However, SQL like databases require that the tables be defined and so you need to auto-migrate/auto-update or create tables manually before you can use them.

kidwm commented 8 years ago

@kraman Thank you for explanation.