Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

arangojs

Package Overview
Dependencies
Maintainers
2
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arangojs - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

lib/route.js

194

lib/collection.js

@@ -6,3 +6,4 @@ /*jshint browserify: true */

inherits = require('util').inherits,
extend = require('extend');
extend = require('extend'),
ArrayCursor = require('./cursor');

@@ -22,3 +23,3 @@ module.exports = extend(

this._connection = connection;
this._api = this._connection.endpoint('_api');
this._api = this._connection.route('_api');
extend(this, body);

@@ -44,2 +45,11 @@ delete this.code;

},
_indexHandle: function (indexHandle) {
if (indexHandle.id) {
indexHandle = indexHandle.id;
}
if (indexHandle.indexOf('/') === -1) {
indexHandle = this.name + '/' + indexHandle;
}
return indexHandle;
},
_get: function (path, update, opts, callback) {

@@ -188,2 +198,182 @@ if (typeof opts === 'function') {

});
},
indexes: function (callback) {
if (!callback) callback = noop;
this._api.get('index', {collection: this.name}, function (err, result) {
if (err) callback(err);
else callback(null, result.indexes);
});
},
index: function (indexHandle, callback) {
if (!callback) callback = noop;
this._api.get(
'index/' + this._indexHandle(indexHandle),
function (err, result) {
if (err) callback(err);
else callback(null, result);
}
);
},
createIndex: function (details, callback) {
if (!callback) callback = noop;
this._api.post('index', details, {
collection: this.name
}, function (err, result) {
if (err) callback(err);
else callback(null, result);
});
},
dropIndex: function (indexHandle, callback) {
if (!callback) callback = noop;
this._api.delete(
'index/' + this._indexHandle(indexHandle),
function (err, result) {
if (err) callback(err);
else callback(null, result);
}
);
},
createCapConstraint: function (size, callback) {
if (typeof size === 'number') {
size = {size: size};
}
if (!callback) callback = noop;
this._api.post('index', extend({}, size, {
type: 'cap'
}), {collection: this.name}, function (err, result) {
if (err) callback(err);
else callback(null, result);
});
},
createHashIndex: function (fields, unique, callback) {
if (typeof unique === 'function') {
callback = unique;
unique = undefined;
}
if (typeof fields === 'string') {
fields = [fields];
}
if (!callback) callback = noop;
this._api.post('index', {
type: 'hash',
fields: fields,
unique: Boolean(unique)
}, {collection: this.name}, function (err, result) {
if (err) callback(err);
else callback(null, result);
});
},
createSkipList: function (fields, unique, callback) {
if (typeof unique === 'function') {
callback = unique;
unique = undefined;
}
if (typeof fields === 'string') {
fields = [fields];
}
if (!callback) callback = noop;
this._api.post('index', {
type: 'skiplist',
fields: fields,
unique: Boolean(unique)
}, {collection: this.name}, function (err, result) {
if (err) callback(err);
else callback(null, result);
});
},
createGeoIndex: function (fields, opts, callback) {
if (typeof opts === 'function') {
callback = opts;
opts = undefined;
}
if (typeof fields === 'string') {
fields = [fields];
}
if (!callback) callback = noop;
this._api.post('index', extend({}, opts, {
type: 'geo',
fields: fields
}), {collection: this.name}, function (err, result) {
if (err) callback(err);
else callback(null, result);
});
},
createFulltextIndex: function (fields, minLength, callback) {
if (typeof minLength === 'function') {
callback = minLength;
minLength = undefined;
}
if (typeof fields === 'string') {
fields = [fields];
}
if (!callback) callback = noop;
this._api.post('index', {
type: 'fulltext',
fields: fields,
minLength: minLength ? Number(minLength) : undefined
}, {collection: this.name}, function (err, result) {
if (err) callback(err);
else callback(null, result);
});
},
fulltext: function (field, query, opts, callback) {
if (typeof opts === 'function') {
callback = opts;
opts = undefined;
}
if (opts) {
opts = extend({}, opts);
if (opts.index) opts.index = this._indexHandle(opts.index);
}
if (!callback) callback = noop;
var self = this;
self._api.put('simple/fulltext', extend(opts, {
collection: this.name,
attribute: field,
query: query
}), function (err, body) {
if (err) callback(err);
else callback(null, new ArrayCursor(self._connection, body));
});
},
near: function (latitude, longitude, opts, callback) {
if (typeof opts === 'function') {
callback = opts;
opts = undefined;
}
if (opts) {
opts = extend({}, opts);
if (opts.geo) opts.geo = this._indexHandle(opts.geo);
}
if (!callback) callback = noop;
var self = this;
self._api.put('simple/near', extend(opts, {
collection: this.name,
latitude: latitude,
longitude: longitude
}), function (err, body) {
if (err) callback(err);
else callback(null, new ArrayCursor(self._connection, body));
});
},
within: function (latitude, longitude, radius, opts, callback) {
if (typeof opts === 'function') {
callback = opts;
opts = undefined;
}
if (opts) {
opts = extend({}, opts);
if (opts.geo) opts.geo = this._indexHandle(opts.geo);
}
if (!callback) callback = noop;
var self = this;
self._api.put('simple/within', extend(opts, {
collection: this.name,
latitude: latitude,
longitude: longitude,
radius: Number(radius)
}), function (err, body) {
if (err) callback(err);
else callback(null, new ArrayCursor(self._connection, body));
});
}

@@ -190,0 +380,0 @@ });

6

lib/connection.js

@@ -9,3 +9,3 @@ /*jshint browserify: true */

ArangoError = require('./error'),
Endpoint = require('./endpoint'),
Route = require('./route'),
jsonMime = /\/(json|javascript)(\W|$)/;

@@ -43,4 +43,4 @@

},
endpoint: function (path) {
return new Endpoint(this, path);
route: function (path) {
return new Route(this, path);
},

@@ -47,0 +47,0 @@ request: function (opts, callback) {

@@ -12,3 +12,3 @@ /*jshint browserify: true */

this._connection = connection;
this._api = this._connection.endpoint('_api');
this._api = this._connection.route('_api');
this._result = body.result;

@@ -15,0 +15,0 @@ this._hasMore = Boolean(body.hasMore);

@@ -19,3 +19,3 @@ /*jshint browserify: true */

this._connection = new Connection(config);
this._api = this._connection.endpoint('_api');
this._api = this._connection.route('_api');
this.name = this._connection.config.databaseName;

@@ -25,4 +25,4 @@ }

extend(Database.prototype, {
endpoint: function (path, headers) {
return this._connection.endpoint(path, headers);
route: function (path, headers) {
return this._connection.route(path, headers);
},

@@ -29,0 +29,0 @@ createCollection: function (properties, callback) {

@@ -13,5 +13,5 @@ /*jshint browserify: true */

this._connection = connection;
this._api = this._connection.endpoint('_api');
this._api = this._connection.route('_api');
extend(this, body);
this._gharial = this._api.endpoint('gharial/' + this.name);
this._gharial = this._api.route('gharial/' + this.name);
}

@@ -91,3 +91,3 @@

BaseCollection.call(this, connection, body);
this._gharial = this._api.endpoint('gharial/' + this.graph.name + '/vertex/' + this.name);
this._gharial = this._api.route('gharial/' + this.graph.name + '/vertex/' + this.name);
}

@@ -118,3 +118,3 @@ inherits(VertexCollection, BaseCollection);

BaseCollection.call(this, connection, body);
this._gharial = this._api.endpoint('gharial/' + this.graph.name + '/edge/' + this.name);
this._gharial = this._api.route('gharial/' + this.graph.name + '/edge/' + this.name);
}

@@ -121,0 +121,0 @@ inherits(EdgeCollection, BaseCollection);

{
"name": "arangojs",
"version": "3.2.0",
"version": "3.3.0",
"description": "The official ArangoDB JavaScript driver.",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc