rockdai / sql-bricks

Transparent, Schemaless SQL Generation
http://csnw.github.io/sql-bricks
MIT License
210 stars 25 forks source link

can not use 'using' after delete #115

Closed BugKun closed 4 years ago

BugKun commented 4 years ago
console.log(sqlBricks.delete().from('test').using)
// undefined

I read the 'sql-bricks.d.ts', then i know i can use 'using' after the delete. But actually, it is not working.And i think i should use 'join', 'leftjoin', etc. But it aslo can not use these

prust commented 4 years ago

@BugKun: the typescript file isn't very helpful in figuring out how to use the library, the docs (http://csnw.github.io/sql-bricks) are much more helpful. They are comprehensive, with lots of examples.

For example, here are the docs for using:

using sel.using(columnList)

Joins using USING instead of ON. columnList can be passed in as one or more string arguments, a comma-delimited string, or an array.

select('*').from('person').innerJoin('address').using('address_id');
// SELECT * FROM person INNER JOIN address USING (address_id)

select('*').from('person').join('address').using('address_id', 'country_id');
// SELECT * FROM person INNER JOIN address USING (address_id, country_id)

select('*').from('person').join('address').using('address_id, country_id');
// SELECT * FROM person INNER JOIN address USING (address_id, country_id)

select('*').from('person').join('address').using(['address_id', 'country_id']);
// SELECT * FROM person INNER JOIN address USING (address_id, country_id)

Note: columnList can also be passed as the second argument to join - in which case it must be specified as an array of one or more string values.

select('*').from('person').join('address', ['address_id', 'country_id']);
// SELECT * FROM person INNER JOIN address USING (address_id, country_id)