{"action":"created","issue":{"url":"https://api.github.com/repos/bravi-software/knextancy/issues/6","repository_url":"https://api.github.com/repos/bravi-software/knextancy","labels_url":"https://api.github.com/repos/bravi-software/knextancy/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/bravi-software/knextancy/issues/6/comments","events_url":"https://api.github.com/repos/bravi-software/knextancy/issues/6/events","html_url":"https://github.com/bravi-software/knextancy/issues/6","id":168558628,"number":6,"title":"Simple example","user":{"login":"robertoclavijob","id":8324592,"avatar_url":"https://avatars.githubusercontent.com/u/8324592?v=3","gravatar_id":"","url":"https://api.github.com/users/robertoclavijob","html_url":"https://github.com/robertoclavijob","followers_url":"https://api.github.com/users/robertoclavijob/followers","following_url":"https://api.github.com/users/robertoclavijob/following{/other_user}","gists_url":"https://api.github.com/users/robertoclavijob/gists{/gist_id}","starred_url":"https://api.github.com/users/robertoclavijob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertoclavijob/subscriptions","organizations_url":"https://api.github.com/users/robertoclavijob/orgs","repos_url":"https://api.github.com/users/robertoclavijob/repos","events_url":"https://api.github.com/users/robertoclavijob/events{/privacy}","received_events_url":"https://api.github.com/users/robertoclavijob/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-01T03:16:51Z","updated_at":"2016-08-02T03:02:54Z","closed_at":null,"body":"Hi: \r\nI am trying to get a simple query running using knextancy, but without success.\r\n\r\nI working with this example\r\nhttps://github.com/dYale/knexBlogBackend/\r\n\r\nI added a route in the index file\r\n\r\n```\r\napp.get('/', function (req, res) {\r\n    db.select().from('users').then(function (result) {\r\n        res.json(result);\r\n    })\r\n});\r\n```\r\n\r\nTesting with postman it works ok.\r\n\r\nThen I tried to use knextancy in this way \r\n```\r\n\r\nvar express = require('express');  \r\nvar app = express();  \r\nvar db  = require('./db');\r\nvar knextancy = require('knextancy');\r\n\r\nvar port = 4000;\r\n\r\napp.listen(port);  \r\nconsole.log(\"Listening on port\", port);\r\n\r\napp.get('/', function (req, res) {\r\n    var tenantId = 1;\r\n    knextancy.tenant(db, tenantId).then(function (tenantKnex) {\r\n\r\n        // the tenantKnex object contains the tenantId as an attribute \r\n        console.log(tenantKnex.tenantId);\r\n\r\n        tenantKnex('$_users').select().then(function (result) {\r\n            res.json(result);\r\n        })\r\n    }).catch(function (error){\r\n        console.log(error);\r\n    });\r\n});\r\n\r\n```\r\nBut I am getting this error in the catch \r\n`Cannot read property 'tableName' of undefined`\r\n\r\nWhat do I need additionally to get it running?\r\n\r\nThanks in advance\r\nRoberto \r\n"},"comment":{"url":"https://api.github.com/repos/bravi-software/knextancy/issues/comments/236781503","html_url":"https://github.com/bravi-software/knextancy/issues/6#issuecomment-236781503","issue_url":"https://api.github.com/repos/bravi-software/knextancy/issues/6","id":236781503,"user":{"login":"robertoclavijob","id":8324592,"avatar_url":"https://avatars.githubusercontent.com/u/8324592?v=3","gravatar_id":"","url":"https://api.github.com/users/robertoclavijob","html_url":"https://github.com/robertoclavijob","followers_url":"https://api.github.com/users/robertoclavijob/followers","following_url":"https://api.github.com/users/robertoclavijob/following{/other_user}","gists_url":"https://api.github.com/users/robertoclavijob/gists{/gist_id}","starred_url":"https://api.github.com/users/robertoclavijob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertoclavijob/subscriptions","organizations_url":"https://api.github.com/users/robertoclavijob/orgs","repos_url":"https://api.github.com/users/robertoclavijob/repos","events_url":"https://api.github.com/users/robertoclavijob/events{/privacy}","received_events_url":"https://api.github.com/users/robertoclavijob/received_events","type":"User","site_admin":false},"created_at":"2016-08-02T03:02:54Z","updated_at":"2016-08-02T03:02:54Z","body":"Thanks Max\r\n\r\nWith 2.1.2 the tables were successfully created.  But when I try to query the tables, consuming get service from postman, I am getting this error\r\n\r\n`Listening on port 4000\r\nError: Error: ENOENT: no such file or directory, scandir '/home/roberto/sites/knexBlogBackend/seeds'\r\n`\r\n**Migrations**\r\n`\r\nexports.up = function(knex, Promise) {\r\n\r\n\treturn Promise.all([\r\n\r\n        knex.schema.createTable('$_users', function(table) {\r\n            table.increments('uid').primary();\r\n            table.string('username');\r\n            table.string('password');\r\n            table.string('name');\r\n            table.string('email');\r\n            table.timestamps();\r\n        }),\r\n\r\n    ])\r\n  \r\n};\r\n\r\nexports.down = function(knex, Promise) {\r\n\r\n\treturn Promise.all([\r\n        knex.schema.dropTable('$_users'),\r\n    ])\r\n  \r\n};`\r\n\r\nThe route\r\n\r\n`var express = require('express');  \r\nvar app = express();  \r\nvar db  = require('./db');\r\nvar knextancy = require('knextancy');\r\n\r\nvar port = 4000;\r\n\r\napp.listen(port);  \r\nconsole.log(\"Listening on port\", port);\r\n\r\napp.get('/', function (req, res) {\r\n    var tenantId = req.headers['x-client-id'];\r\n    knextancy.tenant(db, tenantId).then(function (tenantKnex) {\r\n        // the tenantKnex object contains the tenantId as an attribute\r\n        console.log(tenantKnex.tenantId);\r\n\r\n        tenantKnex('$_users').select().then(function (result) {\r\n            res.json(result);\r\n        })\r\n    }).catch(function (error){\r\n        console.log(\"Error: \" + error);\r\n    });\r\n});`\r\n"}}
{"actor":{"display_login":"robertoclavijob"}}