0

Is it possible to use NodeJs like function Callbacks with ArangoJs 3.x; I have seen that ArangoJs 3.x using .then method (promises).. But I am using NodeJs 4.4 .. so i can't use .then method there.. Can I use nodejs like function callbacks for arangojs 3.x ?

6
  • Why wouldn't you be able to use the .then method there? Commented Jul 26, 2016 at 19:59
  • because .. there is no support for javascript promisses (.then) in node 4.x here you can see .. freature support.. node.green Commented Jul 27, 2016 at 18:18
  • There is no native support for the Promise object but if the ArangoJs library implements them on their own you can still use .then Commented Jul 27, 2016 at 18:40
  • No, Now ArangoJS provides native support for promises .. that's why .then method is there.. and working perfectely with node 6.3 .. but my question is .. is , still is it possible to use nodejs like function call backs instead of then.. i asking this for the sake of backword compability to work with older versions of nodejs(where no promise support..) Commented Jul 28, 2016 at 4:07
  • I don't think you're understanding. Have you tried to use .then? Also, node 4.4 does have native promises Commented Jul 28, 2016 at 15:57

1 Answer 1

1

Quoting the ArangoJS github page:

// ES2015-style
import arangojs, {Database, aql} from 'arangojs';
let db1 = arangojs(); // convenience short-hand
let db2 = new Database();
let {query, bindVars} = aql`RETURN ${Date.now()}`;

// or plain old Node-style
var arangojs = require('arangojs');
var db1 = arangojs();
var db2 = new arangojs.Database();
var aql = arangojs.aql(['RETURN ', ''], Date.now());
var query = aql.query;
var bindVars = aql.bindVars;

// Using a complex connection string with authentication
let host = process.env.ARANGODB_HOST;
let port = process.env.ARANGODB_PORT;
let database = process.env.ARANGODB_DB;
let username = process.env.ARANGODB_USERNAME;
let password = process.env.ARANGODB_PASSWORD;
let db = arangojs({
  url: `http://${username}:${password}@${host}:${port}`,
  databaseName: database
});

// Using ArangoDB 2.8 compatibility mode
let db = arangojs({
  arangoVersion: 20800
});

Isn't that exactly what you were looking for?

Sign up to request clarification or add additional context in comments.

3 Comments

First of all i want to thank for this answer... But this is not exactly what i want.. I have seen it already.. But how can i write same to create a collection.. The same is not working for collections.. if you can please give example to create collection using node js style clalbacks.. because creating collection varies from other stuf..
@shivaraj try db.collection('someCollection').create(function (err, res) {...})?
Thank you very much @AlanPlum , now i get clear with that.. and please change the answer that only explains our main problem.. give collection example too..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.