11.5 表 CRUD 函数

TableSelectFunction

Table.select()collection.find() 使用不同的方法对结果进行排序。Table.select() 遵循 SQL 语言命名,并调用排序方法 orderBy()Collection.find() 则不然。使用 sort() 方法对 Collection.find() 返回的结果进行排序。在这里,与 SQL 标准的接近程度被认为比 API 的一致性更重要。

此函数的 EBNF 语法如下所示:

TableSelectFunction
  ::= '.select(' ProjectedSearchExprStrList? ')' ( '.where(' SearchConditionStr ')' )?
      ( '.groupBy(' SearchExprStrList ')' )? ( '.having(' SearchConditionStr ')' )?
      ( '.orderBy(' SortExprStrList ')' )? ( '.limit(' NumberOfRows ')' ( '.offset(' NumberOfRows ')' )? )?
      ( '.lockExclusive(' LockContention ')' | '.lockShared(' LockContention ')' )? 
      ( '.bind(' ( PlaceholderValues ) ')' )*
      ( '.execute()' )?

图 11.15 TableSelectFunction

Image shows the syntax in EBNF form as described in the preceding text.

TableInsertFunction

此函数的 EBNF 语法如下所示:

TableInsertFunction
  ::= '.insert(' ( TableFields )? ')'
        ( '.values(' ExprOrLiteral (',' ExprOrLiteral)* ')' )+
        ( '.execute()' )?

图 11.16 TableInsertFunction

Image shows the syntax in EBNF form as described in the preceding text.

TableUpdateFunction

此函数的 EBNF 语法如下所示:

TableUpdateFunction
  ::= '.update()'
      ( '.set(' TableField ',' ExprOrLiteral ')' )+ '.where(' SearchConditionStr ')'
      ( '.orderBy(' SortExprStrList ')' )? ( '.limit(' NumberOfRows ')' )?
      ( '.bind(' ( PlaceholderValues ) ')' )*
      ( '.execute()' )?

图 11.17 TableUpdateFunction

Image shows the syntax in EBNF form as described in the preceding text.

TableDeleteFunction

此函数的 EBNF 语法如下所示:

TableDeleteFunction
  ::= '.delete()' '.where(' SearchConditionStr ')'
      ( '.orderBy(' SortExprStrList ')' )? ( '.limit(' NumberOfRows ')' )?
      ( '.bind(' ( PlaceholderValues ) ')' )*
      ( '.execute()' )?

图 11.18 TableDeleteFunction

Image shows the syntax in EBNF form as described in the preceding text.