Skip to content

Instantly share code, notes, and snippets.

@booo
Created September 19, 2011 20:41
Show Gist options
  • Select an option

  • Save booo/1227542 to your computer and use it in GitHub Desktop.

Select an option

Save booo/1227542 to your computer and use it in GitHub Desktop.
orm = require "orm"
orm.connect "postgresql://postgres:testing@localhost/orm", (success, db) ->
if not success then console.log db.message
else
Place = db.define "place", {
description:
type: "string"
geom:
type: "geom"
}
Place.sync()
berlin = new Place {
description: "Berlin"
geom: "POINT(1 1)"
}
berlin.save (error, copy) ->
if error then console.log error
else
console.log berlin.id
fn = ->
Place.find { description: "Berlin" }, (places) ->
if places
console.log places
#db._db._client.end()
db.end()
else console.log "No place with description Berlin"
setTimeout fn, 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment