Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knex:warning - global Knex.raw is deprecated, use knex.raw (chain off an initialized knex object) #20

Closed
unimonkiez opened this issue Jul 1, 2017 · 3 comments

Comments

@unimonkiez
Copy link
Contributor

While running I get his error

Knex:warning - global Knex.raw is deprecated, use knex.raw (chain off an initialized knex object)

Thanks in advance!

@jfgodoy
Copy link
Owner

jfgodoy commented Jul 1, 2017

thank you for the report, I will check it right now.

@jfgodoy
Copy link
Owner

jfgodoy commented Jul 1, 2017

It is not a knex-postgis issue. You need to pass a Knex instance to knex-postgis

Wrong:
This will print warnings

const knex = require('knex');
const st = require('knex-postgis')(knex);
const sql = knex.select('id', st.asText('geom')).from('points').toString();
console.log(sql);

Right:

// create a knex instance
const knex = require('knex')({
  dialect: 'postgres'
  // other params
});
const st = require('knex-postgis')(knex);
const sql = knex.select('id', st.asText('geom')).from('points').toString();
console.log(sql);

@jfgodoy jfgodoy closed this as completed Jul 1, 2017
unimonkiez added a commit to unimonkiez/knex-postgis that referenced this issue Jul 1, 2017
basically the same but updating due not understanding the decumentation correctly in jfgodoy#20.
changes -
* ES6 syntax, it's 2017, ES5 is dead.
* Separate imports from logic, makes better understanding of the examples.
@unimonkiez
Copy link
Contributor Author

Oh thanks man! works great.

Might got confused due to this example, the db creation is in the same line of the import, so I thought you should wrap knex object instead..

I opened a PR (#21) fixing the documentation.

jfgodoy pushed a commit that referenced this issue Jul 1, 2017
basically the same but updating due not understanding the decumentation correctly in #20.
changes -
* ES6 syntax, it's 2017, ES5 is dead.
* Separate imports from logic, makes better understanding of the examples.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants