- v1.10
Document
Basic Operation
Data Model
Data Model Examples
Database Management
Database Management
Backup & Recovery
Aggregation
Replication
Replication Concept
Replication Operations
Reference
Cluster
Cluster Architecture
Cluster Deployment
Sharding
Connector
Reference
Development
C Driver
C++ Driver
C# Driver
Java Driver
PHP Driver
Python Driver
FAQ
- Content
- Comments
- History
SequoiaDB Script
SequoiaDB has a built-in javascript shell, users can communicate with SequoiaDB instance through command lines. It is very useful. Through it, users can manage system, check and run instance or try other things. Shell is a vital tool in SequoiaDB.
Run shell
$ ./sdb > Welcome to SequoiaDB shell! help() for help, Ctrl+c or quit to exit
Shell will automatically connect to SequoiaDB when SequoiaDB starts, so users should start SequoiaDB before using shell.
> y=200 200 > y/20 10
> new Date("2013/04/17"); Wed Apr 17 2013 00:00:00 GMT+0800 (CST) > "hello,world".replace("world","SequoiaDB") hello,SequoiaDB
> function sdb(n){ ... if(n<=1)return 1; ... else return n*sdb(n-1); ... } > sdb(4); 24
SequoiaDB Client
Shell can run any javascript program. But the particular feature of shell is that is a unique SequoiaDB client. When the system is started, with the command "db=new Sdb("localhost",11810)", users can connect to local database in sequoiaDB server and assign it to the global variable "db". This variable is the a main entrance to visit SequoiaDB in shell.
> db localhost:11810 > db.create("foo") //create colleciton space localhost:11810.foo
Users can visit the collection space in it through the variable "db". "db.foo" returns the collection space "foo" in current database. Users can visit collection in it like "db.foo.bar" which returns the collection "bar" in collection "foo". Since users can visit collections in shell, they can execute almost all manipulations in database.
SequoiaDB shell has built-in help documents. It can be accessed by the help() command. For more details on each method, please refer to the SeuoiaDB JavaScript Method List in the Reference section of SequoiaDB Information Center.
-
See Use description:
> help() var db = new Sdb() connect to database use default host 'localhost' and default port 11810 var db = new Sdb('localhost',11810) connect to database use specified host and port var db = new Sdb('ubuntu',11810,'','') connect to database with username and password help(<method>) help on specified method, e.g. help('createCS') db.help() help on db methods db.cs.help() help on collection space cs db.cs.cl access collection cl on collection space cs db.cs.cl.help() help on collection cl db.cs.cl.find() list all records db.cs.cl.find({a:1}) list records where a=1 db.cs.cl.find().help() help on find methods db.cs.cl.count().help() help on count methods print(x), println(x) print out x traceFmt(<type>,<in>,<out>) format trace input(in) to output(out) by type getErr(ret) print error description for return code clear clear the terminal screen history -c clear the history quit exit Takes 0.2993s.
SequoiaDB shell mainly includes 7 levels of operations: database (db), collection space (cs), collection (cl), cursor (cur), replica group (rg), node (nd), and domain (dm). Users need to understand the relationship between different levels. The operations of each level have its own help command:
-
Database level's main operations are user group management, collection space, replica group, domain, snapshot, storage process, backup, transaction, SQL, and error tracing.
Assume the database has been connected, and there is a javascript object named db which is an instance of the database.
Check all the methods of a database:
db.help()
Check a specific method of a database:
db.help("method")
-
Collection Space level's main operation is the management on the collections.
Assume there is a collection space named "foo".
Check all the methods of a collection space:
db.foo.help()
Check a specific method of a collection space:
db.foo.help("method")
-
Collection level's main operations are CRUD, index management, data sharding, and management on the vertical partition table.
Assume "foo" hypothesis in the set space exists in name as "bar" collection.
Check all the methods of a collection:
db.foo.bar.help()
Check a specific method of a collection:
db.foo.bar.help("method")
-
Cursor level's main operations are on the returned data.
find() method, a cursor object will be returned with all the query results in it.
db.foo.bar.find()
or
var cur = db.foo.bar.find()
The first one directly display all the results on the screen, the second one put the results into a cursor.
Check all the methods of a cursor:
db.foo.bar.find().help()
or
cur.help()
Check a specific method of a cursor:
db.foo.bar.find().help("method")
or
cur.help("method")
The methods similar to find() that also return cursor are list(), snapshot(), etc.
-
Replica group level's main operation is the management on the data node.
Assume there is a replica group named "group1" in the database, a javascript object named rg which is a instance of a replica group is obtained by using "var rg = db.getRG("group1")" command.
Check all the methods of a replica group:
rg.help()
Check a specific method of a replica group:
rg.help("method")
-
Node level's main operation is the obtaining of the status information of data nodes.
Assume creating a data node in the replica group named "group1" using "var rn = rg.createNode("ubuntu-dev1", 51000, "/opt/sequoiadb/database/data/51000")", a javascript object named rn which is an instance of the data node will be obtained.
Check all the methods of a node:
rn.help()
Check all the moethds of a node:
rn.help("method")
-
Domain level's main operations are the modification of domains and the obtaining of the domain information.
Assume creating a domain named "domain1" in the database using "var dm = db.createDomain("domain1",["group1","group2"],{AutoSplit:true})" command, a javascript object named dm which is an instance of domain will be obtained.
Check all the methods of a domain:
dm.help()
Check a specific method of a domain:
dm.help("method")
https://developer.mozilla.org//en-US/docs/Web/JavaScript/Language_Resources to check all the automatically generated javascript function API documents provide by shell.
SequoiaDB shell has built-in help documents. It can be accessed by the help() command. For more details on each method, please refer to the SeuoiaDB JavaScript Method List in the Reference section of SequoiaDB Information Center.
-
See Use description:
> help() var db = new Sdb() connect to database use default host 'localhost' and default port 11810 var db = new Sdb('localhost',11810) connect to database use specified host and port var db = new Sdb('ubuntu',11810,'','') connect to database with username and password help(<method>) help on specified method, e.g. help('createCS') db.help() help on db methods db.cs.help() help on collection space cs db.cs.cl access collection cl on collection space cs db.cs.cl.help() help on collection cl db.cs.cl.find() list all records db.cs.cl.find({a:1}) list records where a=1 db.cs.cl.find().help() help on find methods db.cs.cl.count().help() help on count methods print(x), println(x) print out x traceFmt(<type>,<in>,<out>) format trace input(in) to output(out) by type getErr(ret) print error description for return code clear clear the terminal screen history -c clear the history quit exit Takes 0.2993s.
SequoiaDB shell mainly includes 7 levels of operations: database (db), collection space (cs), collection (cl), cursor (cur), replica group (rg), node (nd), and domain (dm). Users need to understand the relationship between different levels. The operations of each level have its own help command:
-
Database level's main operations are user group management, collection space, replica group, domain, snapshot, storage process, backup, transaction, SQL, and error tracing.
Assume the database has been connected, and there is a javascript object named db which is an instance of the database.
Check all the methods of a database:
db.help()
Check a specific method of a database:
db.help("method")
-
Collection Space level's main operation is the management on the collections.
Assume there is a collection space named "foo".
Check all the methods of a collection space:
db.foo.help()
Check a specific method of a collection space:
db.foo.help("method")
-
Collection level's main operations are CRUD, index management, data sharding, and management on the vertical partition table.
Assume "foo" hypothesis in the set space exists in name as "bar" collection.
Check all the methods of a collection:
db.foo.bar.help()
Check a specific method of a collection:
db.foo.bar.help("method")
-
Cursor level's main operations are on the returned data.
find() method, a cursor object will be returned with all the query results in it.
db.foo.bar.find()
or
var cur = db.foo.bar.find()
The first one directly display all the results on the screen, the second one put the results into a cursor.
Check all the methods of a cursor:
db.foo.bar.find().help()
or
cur.help()
Check a specific method of a cursor:
db.foo.bar.find().help("method")
or
cur.help("method")
The methods similar to find() that also return cursor are list(), snapshot(), etc.
-
Replica group level's main operation is the management on the data node.
Assume there is a replica group named "group1" in the database, a javascript object named rg which is a instance of a replica group is obtained by using "var rg = db.getRG("group1")" command.
Check all the methods of a replica group:
rg.help()
Check a specific method of a replica group:
rg.help("method")
-
Node level's main operation is the obtaining of the status information of data nodes.
Assume creating a data node in the replica group named "group1" using "var rn = rg.createNode("ubuntu-dev1", 51000, "/opt/sequoiadb/database/data/51000")", a javascript object named rn which is an instance of the data node will be obtained.
Check all the methods of a node:
rn.help()
Check all the moethds of a node:
rn.help("method")
-
Domain level's main operations are the modification of domains and the obtaining of the domain information.
Assume creating a domain named "domain1" in the database using "var dm = db.createDomain("domain1",["group1","group2"],{AutoSplit:true})" command, a javascript object named dm which is an instance of domain will be obtained.
Check all the methods of a domain:
dm.help()
Check a specific method of a domain:
dm.help("method")
https://developer.mozilla.org//en-US/docs/Web/JavaScript/Language_Resources to check all the automatically generated javascript function API documents provide by shell.
- Latest Comment

2015-02-14