diff --git a/src/service/meta.json b/src/service/meta.json index 9379b33..d5a906b 100644 --- a/src/service/meta.json +++ b/src/service/meta.json @@ -42,6 +42,14 @@ } }, { + "name": "SQLite", + "checked": false, + "value": { + "template": "sqlite", + "require": "feathers-knex", + "deps": ["sqlite3", "feathers-knex"] + } + }, "name": "Mysql", "checked": false, "value": { @@ -50,7 +58,6 @@ "deps": ["mysql", "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 + +};