Documentation Home
X DevAPI User Guide for MySQL Shell in JavaScript Mode
Download this Manual
PDF (US Ltr) - 1.2Mb
PDF (A4) - 1.2Mb


11.5 Table CRUD Functions

TableSelectFunction

Table.select() and collection.find() use different methods for sorting results. Table.select() follows the SQL language naming and calls the sort method orderBy(). Collection.find() does not. Use the method sort() to sort the results returned by Collection.find(). Proximity with the SQL standard is considered more important than API uniformity here.

The syntax for this function shown in EBNF is:

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

Figure 11.15 TableSelectFunction

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

TableInsertFunction

The syntax for this function shown in EBNF is:

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

Figure 11.16 TableInsertFunction

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

TableUpdateFunction

The syntax for this function shown in EBNF is:

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

Figure 11.17 TableUpdateFunction

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

TableDeleteFunction

The syntax for this function shown in EBNF is:

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

Figure 11.18 TableDeleteFunction

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