From ad633f3342d7189086f9a6adc9c2fb537dec8e3e Mon Sep 17 00:00:00 2001 From: Kyle Campbell Date: Tue, 30 May 2017 15:38:41 -0700 Subject: [PATCH] added sqlite support --- src/service/meta.json | 9 ++++ src/service/templates/models/sqlite/meta.json | 7 ++++ .../models/sqlite/templates/service.json | 20 +++++++++ .../models/sqlite/templates/service.model.js | 41 +++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 src/service/templates/models/sqlite/meta.json create mode 100644 src/service/templates/models/sqlite/templates/service.json create mode 100644 src/service/templates/models/sqlite/templates/service.model.js diff --git a/src/service/meta.json b/src/service/meta.json index 7ddadac..09f9802 100644 --- a/src/service/meta.json +++ b/src/service/meta.json @@ -41,6 +41,15 @@ "deps": ["rethinkdbdash", "feathers-rethinkdb"] } }, + { + "name": "SQLite", + "checked": false, + "value": { + "template": "sqlite", + "require": "feathers-knex", + "deps": ["sqlite3", "feathers-knex"] + } + }, { "name": "None", "checked": false, diff --git a/src/service/templates/models/sqlite/meta.json b/src/service/templates/models/sqlite/meta.json new file mode 100644 index 0000000..8f8eab3 --- /dev/null +++ b/src/service/templates/models/sqlite/meta.json @@ -0,0 +1,7 @@ +{ + "prompts": { + "whenNot": "config.sqlite.db", + "name": "config.sqlite.db", + "description": "What database do you want to use?" + } +} diff --git a/src/service/templates/models/sqlite/templates/service.json b/src/service/templates/models/sqlite/templates/service.json new file mode 100644 index 0000000..d7c8310 --- /dev/null +++ b/src/service/templates/models/sqlite/templates/service.json @@ -0,0 +1,20 @@ +{ + "require": "./{{options.name}}.model", + "options": [{ + "db": "config.{{answers.model.template}}.db", + "table":"{{options.name}}", + "paginate": "config.paginate" + }], + "before":{ + "all": [{ "require": "./hooks/before", "options": [] }] + }, + "after":{ + "all": [{ "require": "./hooks/after", "options": [] }] + }, + "filters": { + "all": { + "require": "./filters/default", + "options": [] + } + } +} diff --git a/src/service/templates/models/sqlite/templates/service.model.js b/src/service/templates/models/sqlite/templates/service.model.js new file mode 100644 index 0000000..90def34 --- /dev/null +++ b/src/service/templates/models/sqlite/templates/service.model.js @@ -0,0 +1,41 @@ +const client = require('knex'); +const service = require('feathers-knex'); +const user = require("os").userInfo().username; + +export default function (options) { + + const debug = require('debug')(`feathers:service:${options.table}:sqlite`) + + const model = client({ + client: 'sqlite3', + connection: { + filename: './' + (options.db || 'feathers') + '.sqlite' + } + }); + + var sqlite = service({ + Model: model, + name: options.table, + paginate: options.paginate + }); + + // + + return sqlite; // uncomment, when removing init block + +};