Documentation Home
X DevAPI User Guide
Download this Manual
PDF (US Ltr) - 1.0Mb
PDF (A4) - 1.0Mb
EPUB - 0.7Mb
HTML Download (TGZ) - 0.6Mb
HTML Download (Zip) - 0.7Mb


X DevAPI User Guide  /  Working with Relational Tables  /  SQL CRUD Functions

Pre-General Availability Draft: 2017-04-25

6.1 SQL CRUD Functions

The following SQL CRUD functions are available in X DevAPI.

Table.insert()

The Table.insert() function is used to store data in a relational table in the database. It is executed by the execute() function.

The following example shows how to use the Table.insert() function. The example assumes that the test schema exists and is assigned to the variable db, and that an empty table called my_table exists.

MySQL Shell JavaScript Code

// Accessing an existing table
var myTable = db.getTable('my_table');

// Insert a row of data.
myTable.insert(['id', 'name']).
        values(1, 'Mike').
        values(2, 'Jack').
        execute();

MySQL Shell Python Code

# Accessing an existing table
myTable = db.get_table('my_table')

# Insert a row of data.
myTable.insert(['id', 'name']).values(1, 'Mike').values(2, 'Jack').execute()

Node.js JavaScript Code

// Accessing an existing table
var myTable = db.getTable('my_table');

// Insert a row of data.
myTable.insert(['id', 'name']).
        values(1, 'Mike').
        values(2, 'Jack').
        execute();

C# Code

{
  // Assumptions: test schema assigned to db, empty my_table table exists

  // Accessing an existing table
  var myTable = db.GetTable("my_table");

  // Insert a row of data.
  myTable.Insert("id", "name")
	.Values(1, "Mike")
	.Values(2, "Jack")
	.Execute();
}

Java Code

// Accessing an existing table
Table myTable = db.getTable("my_table");

// Insert a row of data.
myTable.insert("id", "name")
  .values(1, "Mike")
  .values(2, "Jack")
  .execute();

C++ Code

// Accessing an existing table
var myTable = db.getTable("my_table");

// Insert a row of data.
myTable.insert("id", "name")
       .values(1, "Mike")
       .values(2, "Jack")
       .execute();

Figure 6.1 Table.insert() Syntax Diagram

Table.insert() syntax diagram

Table.select()

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.

Figure 6.2 Table.select() Syntax Diagram

Table.select() Syntax Diagram

Table.update()

Figure 6.3 Table.update() Syntax Diagram

Table.update() Syntax Diagram

Table.delete()

Figure 6.4 Table.delete() Syntax Diagram

Table.delete() Syntax Diagram


User Comments
Sign Up Login You must be logged in to post a comment.