rockdai / sql-bricks

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

Add returning clause to delete statement (postgresql) #41

Closed lyxell closed 10 years ago

lyxell commented 10 years ago

del('user').where({'lname': 'Flintstone'}).returning('') now results in DELETE FROM "user" WHERE lname = 'Flintstone' RETURNING

prust commented 10 years ago

Looks perfect, thanks @lyxell! Merging.

prust commented 10 years ago

@lyxell: This has been published to npm in v0.14.0.

Since you're using Postgres, you may be interested in https://github.com/Suor/pg-bricks.

Also, I noticed your https://github.com/lyxell/backbone-node project. I've been using backbone on the server some, but found that the Backbone.sync API (though it maps really well to REST on the client) doesn't work really well for the SQL what I wanted to do on the server. You may be interested in Ampersand.js, which is an evolution of Backbone, but done in node's mini-module style, with node CommonJS modules. It's mostly designed for use on the client, using Browserify, but where applicable I believe the modules also run on the server (for instance the Model and Events modules).

The Model module is actually broken up into two: an underlying State module which has an inner hash of attributes and broadcasts events when they change, and, layered on top of that, a Model module that includes RESTful API additions. Anyway, I thought you might be interested.

lyxell commented 10 years ago

@prust Thanks!