Wu Bigo

Today I Learned

A collection of concise write-ups about what i learned today and it's build from http://bigo.github.io .These are things that don't really warrant a full blog post


arrangodb note

1: ArangoDB automatically indexes the _key attribute in each collection. There is no need to index this attribute separately. Please note that a document’s _id attribute is derived from the _key attribute, and is thus implicitly indexed, too.

2: Creating a database

We don’t want to mess with any existing data, so let’s start by creating a new database called “mydb”:

db.createDatabase(‘mydb’).then( () => console.log(‘Database created’), err => console.error(‘Failed to create database:’, err) );

Because we’re trying to actually do something on the server, this action is asynchronous. All asynchronous methods in the ArangoDB driver return promises but you can also pass a node-style callback instead:

db.createDatabase(‘mydb’, function (err) { if (!err) console.log(‘Database created’); else console.error(‘Failed to create database:’, err); });

Keep in mind that the new database you’ve created is only available once the callback is called or the promise is resolved. Throughout this tutorial we’ll use the promise API because they’re available in recent versions of Node.js as well as most modern browsers.

3: db = require(‘arangojs’).Database; db = new Database(‘http://127.0.0.1:8529’); db.useBasicAuth(‘root’, ‘123123’); db.createDatabase(‘mydb’).then( () => console.log(‘Database created’), err => console.error(‘Failed to create database:’, err) );

check arangodb status

/etc/init.d/arangodb3 status

enable remote connection

/etc/arangodb3/arangod.conf #endpoint = tcp://[::]:8529