{"id":13500725,"url":"https://github.com/codemix/oriento","last_synced_at":"2025-04-06T22:07:38.455Z","repository":{"id":14737148,"uuid":"17458040","full_name":"codemix/oriento","owner":"codemix","description":"Former official node.js driver for OrientDB. Fast, lightweight, uses the binary protocol. Now deprecated.","archived":false,"fork":false,"pushed_at":"2015-06-26T16:57:28.000Z","size":3556,"stargazers_count":196,"open_issues_count":1,"forks_count":34,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-03-30T20:12:12.158Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"apache/phoenix","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codemix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-05T22:48:02.000Z","updated_at":"2024-03-28T00:22:05.000Z","dependencies_parsed_at":"2022-09-26T16:21:14.266Z","dependency_job_id":null,"html_url":"https://github.com/codemix/oriento","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemix%2Foriento","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemix%2Foriento/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemix%2Foriento/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemix%2Foriento/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemix","download_url":"https://codeload.github.com/codemix/oriento/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557767,"owners_count":20958047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:01:11.752Z","updated_at":"2025-04-06T22:07:38.432Z","avatar_url":"https://github.com/codemix.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# NOTE: Oriento is deprecated, development continues at https://github.com/orientechnologies/orientjs\n\n\n# Oriento\n\nOfficial [orientdb](http://www.orientechnologies.com/orientdb/) driver for node.js. Fast, lightweight, uses the binary protocol.\n\n[![Build Status](https://travis-ci.org/codemix/oriento.svg?branch=master)](https://travis-ci.org/codemix/oriento)\n[![Gitter chat](https://badges.gitter.im/codemix/oriento.png)](https://gitter.im/codemix/oriento)\n\n\n# Supported Versions\n\nOriento aims to work with version 1.7.1 of orientdb and later. While it may work with earlier versions, they are not currently supported, [pull requests are welcome!](./CONTRIBUTING.md)\n\n\u003e **IMPORTANT**: Oriento does not currently support OrientDB's Tree Based [RIDBag](https://github.com/orientechnologies/orientdb/wiki/RidBag) feature because it relies on making additional network requests.\n\u003e This means that by default, the result of e.g. `JSON.stringify(record)` for a record with up to 119 edges will be very different from a record with 120+ edges.\n\u003e This can lead to very nasty surprises which may not manifest themselves during development but could appear at any time in production.\n\u003e There is an [open issue](https://github.com/orientechnologies/orientdb/issues/2315) for this in OrientDB, until that gets fixed, it is **strongly recommended** that you set `RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD` to a very large value, e.g. 2147483647.\n\u003e Please see the [relevant section in the OrientDB manual](http://www.orientechnologies.com/docs/2.0/orientdb.wiki/RidBag.html#configuration) for more information.\n\n# Installation\n\nInstall via npm.\n\n```sh\nnpm install oriento\n```\n\n# Running Tests\n\nTo run the test suite, first invoke the following command within the repo, installing the development dependencies:\n\n```sh\nnpm install\n```\n\nThen run the tests:\n\n```sh\nnpm test\n```\n\n# Features\n\n- Tested with latest orientdb (1.7).\n- Intuitive API, based on [bluebird](https://github.com/petkaantonov/bluebird) promises.\n- Fast binary protocol parser.\n- Access multiple databases via the same socket.\n- Migration support.\n- Simple CLI.\n- Connection Pooling\n\n# Usage\n\n### Configuring the client.\n\n```js\nvar Oriento = require('oriento');\n\nvar server = Oriento({\n  host: 'localhost',\n  port: 2424,\n  username: 'root',\n  password: 'yourpassword'\n});\n```\n\n\n### Listing the databases on the server\n\n```js\nserver.list()\n.then(function (dbs) {\n  console.log('There are ' + dbs.length + ' databases on the server.');\n});\n```\n\n### Creating a new database\n\n```js\nserver.create({\n  name: 'mydb',\n  type: 'graph',\n  storage: 'plocal'\n})\n.then(function (db) {\n  console.log('Created a database called ' + db.name);\n});\n```\n\n### Using an existing database\n\n```js\nvar db = server.use('mydb');\nconsole.log('Using database: ' + db.name);\n```\n\n### Using an existing database with credentials\n\n```js\nvar db = server.use({\n  name: 'mydb',\n  username: 'admin',\n  password: 'admin'\n});\nconsole.log('Using database: ' + db.name);\n```\n\n### Execute an Insert Query\n\n```js\ndb.query('insert into OUser (name, password, status) values (:name, :password, :status)',\n  {\n    params: {\n      name: 'Radu',\n      password: 'mypassword',\n      status: 'active'\n    }\n  }\n).then(function (response){\n  console.log(response); //an Array of records inserted\n});\n\n```\n\n\n### Execute a Select Query with Params\n\n```js\ndb.query('select from OUser where name=:name', {\n  params: {\n    name: 'Radu'\n  },\n  limit: 1\n}).then(function (results){\n  console.log(results);\n});\n\n```\n\n### Raw Execution of a Query String with Params\n\n```js\ndb.exec('select from OUser where name=:name', {\n  params: {\n    name: 'Radu'\n  }\n}).then(function (response){\n  console.log(response.results);\n});\n\n```\n\n### Query Builder: Insert Record\n\n```js\ndb.insert().into('OUser').set({name: 'demo', password: 'demo', status: 'ACTIVE'}).one()\n.then(function (user) {\n  console.log('created', user);\n});\n```\n\n### Query Builder: Update Record\n\n```js\ndb.update('OUser').set({password: 'changed'}).where({name: 'demo'}).scalar()\n.then(function (total) {\n  console.log('updated', total, 'users');\n});\n```\n\n### Query Builder: Delete Record\n\n```js\ndb.delete().from('OUser').where({name: 'demo'}).limit(1).scalar()\n.then(function (total) {\n  console.log('deleted', total, 'users');\n});\n```\n\n\n### Query Builder: Select Records\n\n```js\ndb.select().from('OUser').where({status: 'ACTIVE'}).all()\n.then(function (users) {\n  console.log('active users', users);\n});\n```\n\n### Query Builder: Text Search\n\n```js\ndb.select().from('OUser').containsText({name: 'er'}).all()\n.then(function (users) {\n  console.log('found users', users);\n});\n```\n\n### Query Builder: Select Records with Fetch Plan\n\n```js\ndb.select().from('OUser').where({status: 'ACTIVE'}).fetch({role: 5}).all()\n.then(function (users) {\n  console.log('active users', users);\n});\n```\n\n### Query Builder: Select an expression\n\n```js\ndb.select('count(*)').from('OUser').where({status: 'ACTIVE'}).scalar()\n.then(function (total) {\n  console.log('total active users', total);\n});\n```\n\n### Query Builder: Traverse Records\n\n```js\ndb.traverse().from('OUser').where({name: 'guest'}).all()\n.then(function (records) {\n  console.log('found records', records);\n});\n```\n\n### Query Builder: Return a specific column\n\n```js\ndb\n.select('name')\n.from('OUser')\n.where({status: 'ACTIVE'})\n.column('name')\n.all()\n.then(function (names) {\n  console.log('active user names', names.join(', '));\n});\n```\n\n\n### Query Builder: Transform a field\n\n```js\ndb\n.select('name')\n.from('OUser')\n.where({status: 'ACTIVE'})\n.transform({\n  status: function (status) {\n    return status.toLowerCase();\n  }\n})\n.limit(1)\n.one()\n.then(function (user) {\n  console.log('user status: ', user.status); // 'active'\n});\n```\n\n\n### Query Builder: Transform a record\n\n```js\ndb\n.select('name')\n.from('OUser')\n.where({status: 'ACTIVE'})\n.transform(function (record) {\n  return new User(record);\n})\n.limit(1)\n.one()\n.then(function (user) {\n  console.log('user is an instance of User?', (user instanceof User)); // true\n});\n```\n\n\n### Query Builder: Specify default values\n\n```js\ndb\n.select('name')\n.from('OUser')\n.where({status: 'ACTIVE'})\n.defaults({\n  something: 123\n})\n.limit(1)\n.one()\n.then(function (user) {\n  console.log(user.name, user.something);\n});\n```\n\n\n### Query Builder: Put a map entry into a map\n\n```js\ndb\n.update('#1:1')\n.put('mapProperty', {\n  key: 'value',\n  foo: 'bar'\n})\n.scalar()\n.then(function (total) {\n  console.log('updated', total, 'records');\n});\n```\n\n\n### Loading a record by RID.\n\n```js\ndb.record.get('#1:1')\n.then(function (record) {\n  console.log('Loaded record:', record);\n});\n```\n\n### Deleting a record\n\n```js\ndb.record.delete('#1:1')\n.then(function () {\n  console.log('Record deleted');\n});\n```\n\n### Listing all the classes in the database\n\n```js\ndb.class.list()\n.then(function (classes) {\n  console.log('There are ' + classes.length + ' classes in the db:', classes);\n});\n```\n\n### Creating a new class\n\n```js\ndb.class.create('MyClass')\n.then(function (MyClass) {\n  console.log('Created class: ' + MyClass.name);\n});\n```\n\n### Creating a new class that extends another\n\n```js\ndb.class.create('MyOtherClass', 'MyClass')\n.then(function (MyOtherClass) {\n  console.log('Created class: ' + MyOtherClass.name);\n});\n```\n\n### Getting an existing class\n\n```js\ndb.class.get('MyClass')\n.then(function (MyClass) {\n  console.log('Got class: ' + MyClass.name);\n});\n```\n\n### Updating an existing class\n\n```js\ndb.class.update({\n  name: 'MyClass',\n  superClass: 'V'\n})\n.then(function (MyClass) {\n  console.log('Updated class: ' + MyClass.name + ' that extends ' + MyClass.superClass);\n});\n```\n\n### Listing properties in a class\n\n```js\nMyClass.property.list()\n.then(function (properties) {\n  console.log('The class has the following properties:', properties);\n});\n```\n\n### Adding a property to a class\n\n```js\nMyClass.property.create({\n  name: 'name',\n  type: 'String'\n})\n.then(function () {\n  console.log('Property created.')\n});\n```\n\n### Deleting a property from a class\n\n```js\nMyClass.property.drop('myprop')\n.then(function () {\n  console.log('Property deleted.');\n});\n```\n\n### Renaming a property on a class\n\n```js\nMyClass.property.rename('myprop', 'mypropchanged');\n.then(function () {\n  console.log('Property renamed.');\n});\n```\n\n### Creating a record for a class\n\n```js\nMyClass.create({\n  name: 'John McFakerton',\n  email: 'fake@example.com'\n})\n.then(function (record) {\n  console.log('Created record: ', record);\n});\n```\n\n### Listing records in a class\n\n```js\nMyClass.list()\n.then(function (records) {\n  console.log('Found ' + records.length + ' records:', records);\n});\n```\n\n### Create a new index for a class property\n\n```js\ndb.index.create({\n  name: 'MyClass.myProp',\n  type: 'unique'\n})\n.then(function(index){\n  console.log('Created index: ', index);\n});\n```\n\n### Get entry from class property index\n\n```js\ndb.index.get('MyClass.myProp')\n.then(function (index) {\n  index.get('foo').then(console.log.bind(console));\n});\n```\n\n### Creating a new, empty vertex\n\n```js\ndb.create('VERTEX', 'V').one()\n.then(function (vertex) {\n  console.log('created vertex', vertex);\n});\n```\n\n### Creating a new vertex with some properties\n\n```js\ndb.create('VERTEX', 'V')\n.set({\n  key: 'value',\n  foo: 'bar'\n})\n.one()\n.then(function (vertex) {\n  console.log('created vertex', vertex);\n});\n```\n### Deleting a vertex\n\n```js\ndb.delete('VERTEX')\n.where('@rid = #12:12')\n.one()\n.then(function (count) {\n  console.log('deleted ' + count + ' vertices');\n});\n```\n\n### Creating a simple edge between vertices\n\n```js\ndb.create('EDGE', 'E')\n.from('#12:12')\n.to('#12:13')\n.one()\n.then(function (edge) {\n  console.log('created edge:', edge);\n});\n```\n\n\n### Creating an edge with properties\n\n```js\ndb.create('EDGE', 'E')\n.from('#12:12')\n.to('#12:13')\n.set({\n  key: 'value',\n  foo: 'bar'\n})\n.one()\n.then(function (edge) {\n  console.log('created edge:', edge);\n});\n```\n\n### Deleting an edge between vertices\n\n```js\ndb.delete('EDGE', 'E')\n.from('#12:12')\n.to('#12:13')\n.scalar()\n.then(function (count) {\n  console.log('deleted ' + count + ' edges');\n});\n```\n\n### Creating a function\nYou can create a function by supplying a plain javascript function. Please note that the method stringifies the `function` passed so you can't use any varaibles outside the function closure.\n\n```js\ndb.createFn(\"nameOfFunction\", function(arg1, arg2) {\n  return arg1 + arg2;\n})\n.then(function (count) {\n  // Function created!\n});\n```\n\nYou can also omit the name and it'll default to the `Function#name`\n\n```js\ndb.createFn(function nameOfFunction(arg1, arg2) {\n  return arg1 + arg2;\n})\n.then(function (count) {\n  // Function created!\n});\n```\n\n\n# CLI\n\nAn extremely minimalist command line interface is provided to allow\ndatabases to created and migrations to be applied via the terminal.\n\nTo be useful, oriento requires some arguments to authenticate against the server. All operations require the `password` argument unless the user is configured with an empty password. For operations that involve a specific db, include the `dbname` argument (with `dbuser` and `dbpassword` if they are set to something other than the default).\n\nYou can get a list of the supported arguments using `oriento --help`.\n\n```sh\n  -d, --cwd         The working directory to use.\n  -h, --host        The server hostname or IP address.\n  -p, --port        The server port.\n  -u, --user        The server username.\n  -s, --password    The server password.\n  -n, --dbname      The name of the database to use.\n  -U, --dbuser      The database username.\n  -P, --dbpassword  The database password.\n  -?, --help        Show the help screen.\n```\n\nIf it's too tedious to type these options in every time, you can also create an `oriento.opts` file containing them. Oriento will search for this file in the working directory and apply any arguments it contains.\nFor an example of such a file, see [test/fixtures/oriento.opts](./test/fixtures/oriento.opts).\n\n\n\u003e Note: For brevity, all these examples assume you've installed oriento globally (`npm install -g oriento`) and have set up an oriento.opts file with your server and database credentials.\n\n## Database CLI Commands.\n\n### Listing all the databases on the server.\n\n```sh\noriento db list\n```\n\n### Creating a new database\n\n```sh\noriento db create mydb graph plocal\n```\n\n### Destroying an existing database\n\n```sh\noriento db drop mydb\n```\n\n## Migrations\n\nOriento supports a simple database migration system. This makes it easy to keep track of changes to your orientdb database structure between multiple environments and distributed teams.\n\nWhen you run a migration command, oriento first looks for an orient class called `Migration`. If this class doesn't exist it will be created.\nThis class is used to keep track of the migrations that have been applied.\n\nOriento then looks for migrations that have not yet been applied in a folder called `migrations`. Each migration consists of a simple node.js module which exports two methods - `up()` and `down()`. Each method receives the currently selected database instance as an argument.\n\nThe `up()` method should perform the migration and the `down()` method should undo it.\n\n\u003e Note: Migrations can incur data loss! Make sure you back up your database before migrating up and down.\n\nIn addition to the command line options outlined below, it's also possible to use the migration API programatically:\n\n```js\nvar db = server.use('mydb');\n\nvar manager = new Oriento.Migration.Manager({\n  db: db,\n  dir: __dirname + '/migrations'\n});\n\nmanager.up(1)\n.then(function () {\n  console.log('migrated up by one!')\n});\n```\n\n\n### Listing the available migrations\n\nTo list all the unapplied migrations:\n\n```sh\noriento migrate list\n```\n\n### Creating a new migration\n\n```sh\noriento migrate create my new migration\n```\n\ncreates a file called something like `m20140318_200948_my_new_migration` which you should edit to specify the migration up and down methods.\n\n\n### Migrating up fully\n\nTo apply all the migrations:\n\n```sh\noriento migrate up\n```\n\n### Migrating up by 1\n\nTo apply only the first migration:\n\n```sh\noriento migrate up 1\n```\n\n### Migrating down fully\n\nTo revert all migrations:\n\n```sh\noriento migrate down\n```\n\n### Migrating down by 1\n\n```sh\noriento migrate down 1\n```\n\n## Events\nYou can also bind to the following events\n\n### `beginQuery`\nGiven the query\n\n    db.select('name, status').from('OUser').where({\"status\": \"active\"}).limit(1).fetch({\"role\": 1}).one();\n\nThe following event will be triggered\n\n    db.on(\"beginQuery\", function(obj) {\n      // =\u003e {\n      //  query: 'SELECT name, status FROM OUser WHERE status = :paramstatus0 LIMIT 1',\n      //  mode: 'a',\n      //  fetchPlan: 'role:1',\n      //  limit: -1,\n      //  params: { params: { paramstatus0: 'active' } }\n      // }\n    });\n\n\n### `endQuery`\nAfter a query has been run, you'll get the the following event emitted\n\n    db.on(\"endQuery\", function(obj) {\n      // =\u003e {\n      //   \"err\": errObj,\n      //   \"result\": resultObj,\n      //   \"perf\": {\n      //     \"query\": timeInMs\n      //   }\n      // }\n    });\n\n\n# History\n\nIn 2012, [Gabriel Petrovay](https://github.com/gabipetrovay) created the original [node-orientdb](https://github.com/gabipetrovay/node-orientdb) library, with a straightforward callback based API.\n\nIn early 2014, [Giraldo Rosales](https://github.com/nitrog7) made a [whole host of improvements](https://github.com/nitrog7/node-orientdb), including support for orientdb 1.7 and switched to a promise based API.\n\nLater in 2014, [codemix](http://codemix.com/) refactored the library to make it easier to extend and maintain, and introduced an API similar to [nano](https://github.com/dscape/nano). The result is so different from the original codebase that it warranted its own name and npm package. This also gave us the opportunity to switch to semantic versioning.\n\n\n# Notes for contributors\n\nPlease see [CONTRIBUTING](./CONTRIBUTING.md).\n\n# Changes\n\nSee [CHANGELOG](./CHANGELOG.md)\n\n\n\n# License\n\nApache 2.0 License, see [LICENSE](./LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemix%2Foriento","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemix%2Foriento","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemix%2Foriento/lists"}