UNPKG

2.79 kBtext/coffeescriptView Raw
1###
2There are a few subsystems that make up gesundheit, but the majority of use
3cases will be covered by using the following properties of the main module:
4
5 **gesundheit.{Select, SELECT, select}**
6 Function for creating new :class:`queries/select::SelectQuery` instances.
7
8 **gesundheit.{Update, UPDATE, update}**
9 Function for creating new :class:`queries/update::UpdateQuery` instances.
10
11 **gesundheit.{Delete, DELETE, delete}**
12 Function for creating new :class:`queries/delete::DeleteQuery` instances.
13
14 **gesundheit.{Insert, INSERT, insert}**
15 Function for creating new :class:`queries/insert::InsertQuery` instances.
16
17 **gesundheit.engine**
18 Function for creating new :mod:`engines`.
19
20 **gesundheit.defaultEngine**
21 The engine that will be used for queries that aren't explicitly bound. This
22 is set to a no-op engine that you will want to replace with either an object
23 returned by the ``gesundheit.engine`` function or by implementing the engine
24 interface yourself.
25
26 **Join types**
27 Constant nodes for use with :meth:`queries/sud::SUDQuery.join`.
28 'LEFT', 'RIGHT', 'INNER', 'LEFT_OUTER', 'RIGHT_OUTER', 'FULL_OUTER'
29 'NATURAL', 'CROSS'
30
31 **AST helper functions**
32 These come from the `nodes <#module-nodes::>`_ module and are often useful
33 when constructing complicated queries:
34
35 :func:`nodes::toParam`
36 Convert any object to a parameter placeholder.
37 :func:`nodes::toRelation`
38 Convert various inputs to :class:`nodes::Relation` nodes.
39 :func:`nodes::binaryOp`
40 Create a binary comparison node manually. (e.g. for postgres' custom
41 operators).
42 :func:`nodes::sqlFunction`
43 Create SQL function calls (e.g. ``MAX(last_update)``)
44 :func:`nodes::text`
45 Include raw SQL in a query, with parameter placeholders.
46
47If you are implementing support for a different database engine or constructing
48particularly unusual SQL statements, you might also want to make use of these:
49
50 **gesundheit.nodes**
51 The `nodes <Nodes>` module.
52
53 **gesundheit.dialects**
54 The `dialects <Dialects>` module.
55
56###
57exports.dialects = require './dialects'
58exports.engine = require './engine'
59exports.defaultEngine = exports.engine 'fake://localhost/'
60
61exports.nodes = require './nodes'
62
63for name, node of exports.nodes.CONST_NODES
64 exports[name] = exports.nodes.CONST_NODES[name]
65
66for name, node of exports.nodes.JOIN_TYPES
67 exports[name] = exports.nodes.JOIN_TYPES[name]
68
69for name, helper of exports.nodes when name[0] is name[0].toLowerCase()
70 exports[name] = helper
71
72require('./queries').mixinFactoryMethods(exports, -> exports.defaultEngine)
73
74exports.begin = (args...) ->
75 exports.defaultEngine.begin args...
76
77exports.query = (args...) ->
78 exports.defaultEngine.query args...