v1.10

Document

How to Start SequoiaDB

Basic Operation

Data Model

Database Management

Aggregation

Index

Replication

Cluster

Connector

Reference

Development

Release Note

FAQ

  • Content
  • Comments
  • History

SequoiaDB Commands

Sequoiadb is a kind of file-based non-relation database. It usesJSON data module.
  • If users want to match elements nested in an object. They can use "." ("0x2E" in ASCII) to connect parent element and child element. For example, in this object:
    { name:"tom",address:{ street:{ street1:"1024 Wall Street",street2:"University Drive"},zipcode: 100000 } }
    If users want to match the element "street" in the object "street" in the object "address", they can get it in this way:
    { "address.street.street1":{ $exists : 1 } }
  • If there is an array in an object, users can get the 1st, 2nd, and 3rd element by "0", "1" and "2" respectively. For example, this object cantains am array:
    { name: "tom", phone: [ "13175824", "1528345"] }
    Users can get the 1st element in the array in this way:
    { "phone.0 ":"13175824" }

Database Operation Methods

Method Name Description Sample
db.createCS() Create a collectin space db.createCS("foo")
db.dropCS() Delete a collection space db.dropCS("foo")
db.getCS() Get the quotation of a collection space db.getCS("foo")
db.createRG() Create a replset db.createRG("rg")
db.removeRG() Remove a replset db.removeRG("rg")
db.getRG() Get the quotation of a replset db.getRG("rg")
db.list() Enumerate lists db.list()
db.listCollectionSpaces() Enumerate collection spaces db.listCollectionSpaces()
db.listCollections() Enumerate collections db.listCollections()
db.listReplicaGroups() Enumerate replsets db.listReplicaGroups()
db.snapshot() Enumerate snapshots db.snapshot(0)
db.resetSnapshot() Reset a snapshot db.resetSnapshot(0)
db.startRG() Start a replset db.startRG("rgName")
db.createUsr() Create a database user db.createUsr("root","admin")
db.dropUsr() Delete a databse user db.dropUsr("root","admin")
db.transBegin() Open the rtansaction db.transBegin()
db.transCommit() Commit the transaction db.transCommit()
db.transRollback() Transaction rollback db.transRollback()
db.createProcedure() Create a stored procedure functions db.createProcedure(function sum(i,j){return i+j;})
db.removeProcedure() Delete stored procedure function that already exists db.removeProcedure("sum")
db.listProcedures() Enumeration stored procedure functions db.listProcedures()
db.eval() Call a stored procedure or function directly using javaScript statement db.eval('db.foo.bar')

Collection Space Method

Method Name Description Sample
db.collectionspace.createCL() Create a collection db.foo.createCL("bar")
db.collectionspace.dropCL() Delete a collection db.foo.dropCL("bar")
db.collectionspace.getCL() Get the quotation of a collection db.foo.getCL("bar")

Collection Method

Method Name Description Sample
db.collectionspace.collection.insert() Insert a record into a collection db.foo.bar.insert({name:"Tom",age:20, phone:[123,345]})
db.collectionspace.collection.count() Count the records in a collection db.foo.bar.count({age:{$gt:20}})
db.collectionspace.collection.find() Find records db.foo.bar.find()
db.collectionspace.collection.aggregate() Gather records db.foo.bar.aggregate({$project:{name:1,age:1}}, {$group:{_id:"$sex"}})
db.collectionspace.collection.remove() Delete records db.foo.bar.remove()
db.collectionspace.collection.createIndex() Create an index db.foo.bar.createIndex("myIndex",{age:-1}, false)
db.collectionspace.collection.dropIndex() Delete an index db.foo.bar.dropIndex("myIndex")
db.collectionspace.collection.getIndex() Get the quotation of an index db.foo.bar.getIndex("myIndex")
db.collectionspace.collection.listIndexes() Enumerate indexes db.foo.bar.listIndexes()
db.collectionspace.collection.update() Update records db.foo.bar.update({$set:{age:25}},{age:{$lte:20}}, {"":"myIndex"})
db.collectionspace.collection.upset() Update records db.foo.bar.update({$set:{age:25}},{a:1}, {"":"myIndex"})
db.collectionspace.collection.split() Split a collection db.foo.bar.split("sourceRG","targetRG", {age:20})

Cluster Method

Method Name Description Sample
rg.start() Start replset rg.start()
rg.getDetail() Get information of replset rg.getDetail()
rg.createNode() Create node rg.createNode(,,)
rg.removeNode() Delete node rg.removeNode(,[,])
rg.getMaster() Get information of master node rg.getMaster()
rg.getSlave() Get information of slave node rg.getSlave()
rg.getNode() Get information of all nodes rg.getNode()
rg.stop() Stop a replset rg.stop()

Node Method

Method Name Description Sample
node.start() Start a node node.start()
node.connect() Get the hostname and port of a connected node node.connect()
node.getHostName() Get the host name of a node node.getHostName()
node.getServiceName() Get the server name of a node node.getServiceName()
node.getNodeDetail() Get information of a node node.getNodeDetail()
node.stop() Stop a node node.stop()

Cursor Method

Method Name Description Sample
cursor.sort() Sort result set according to the specified field db.foo.bar.find().sort({age:1})
cursor.hint() Go through result set according to the specified index db.foo.bar.find().hint({"":"Index"})
cursor.limit() Specify the amount of records to be returned in the result set db.foo.bar.find().limit(10)
cursor.skip() Specify the first record to be returned in the result set db.foo.bar.find().skip(10)
cursor.current() Return the record that the current cursor currently pionts to db.foo.bar.find().current()
cursor.next() Return the next record in the cursor db.foo.bar.find().next()
cursor.size() Return the distance from the record that the current cusor pionts to to the final record db.foo.bar.find().size()
cursor.toArray() Return result set in the format of array db.foo.bar.find.toArray()
please login to comment.
Latest Comment
  • 2015-02-15

About Us

SequoiaDB is a financial-level distributed database vendor and is the first Chinese database listed in Gartner’s Magic Quadrant OPDBMS report. SequoiaDB has recently released version 3.0.
SequoiaDB is now penetrating the vertical sector Financial Industry quickly and had more than 50 banking clients and hundreds of enterprise customers in industries including government, telecommunication, Internet and IoT.

Beijing:
Tower R, No.8 North Star East Road, Chaoyang District, Beijing,China
Guangzhou:
Tower A, No.22 Qinglan Street, Panyu District, Guangzhou,China
Shenzhen:
Tsing Hua Tech Park, Nanshan District, Shenzhen,China
Tel:400-8038-339
E-mail:contact@sequoiadb.com