Test Page

{
  "id": "2020-11-25-integrating-blockchain-secured-data-with-node-js-and-ebakusng",
  "data": {
    "title": "Integrating Blockchain secured data with node.js and EbakusNG",
    "description": "",
    "pubDate": "2020-11-25T11:41:52.000Z"
  },
  "body": "EbakusNG\\* is a next generation blockchain software that, among other things, can be used as **a secure drop-in replacement for traditional databases.**\n\nSuppose you need a secure datastore for your application’s medical records. **These are patient’s sensitive data, that need to be verifiably correct and secured across multiple clinics in a hospital and possibly securely and trustlessly shared with insurance companies.** Let’s see how this can be implemented in a node.js application using EbakusNG as a blockchain enabled database.\n\n#### Installing the node.js library\n\nIn order to use the EbakusDB through Node.js you first have to install the client library. For doing this you simply run:\n\n```bash\n$ npm install node-ebakusdb --save\n```\n\n#### Defining the database schema\n\nBefore continuing with the actual code and how to use the library, we have to define some models that we are going to use in our DB. For this post let’s use the following ones:\n\n```javascript\nconst schemas = {\n  Patients: {\n    type: 'table',\n    name: 'Patients',\n    inputs: [\n      { name: 'Id', type: 'string' },\n      { name: 'FirstName', type: 'string' },\n      { name: 'LastName', type: 'string' },\n      { name: 'Email', type: 'string' },\n      { name: 'SocialSecurityNumber', type: 'string' },\n      // ...\n    ],\n  },\n  Exams: {\n    type: 'table',\n    name: 'Exams',\n    inputs: [\n      { name: 'Id', type: 'string' },\n      { name: 'PatientId', type: 'string' },\n      { name: 'Date', type: 'uint64' },\n      { name: 'Info', type: 'string' },\n      // ...\n    ],\n  },\n}\n```\n\nThe above schema describes two tables, one for **Patients** and one for **medical exams** they might have performed.\n\n#### Creating our connection object\n\nNow that we have our models let’s create a client connection object.\n\n**_For this type of application you might want to run private ebakus nodes deployed at various clinics. This is as easy to do as launching a mysql server, and we will cover this in a next tutorial. So stay tuned._** \n\n```javascript\nconst ebakusdb = require('ebakusdb')\nconst client = ebakusdb.createClient({\n  secure: true,\n  host: 'rpc.ebakus-testnet.com',\n  port: 443,\n  localSigning: true,\n  keystoreV3: '/examples/keystoreV3.json',\n  keystoreV3Pass: '123',\n  schema: schemas // as defined previously\n})\n```\n\nSo are we ready? In some sense, yes. You have a connection to a blockchain network that has a DB. You can now send commands to the database.\n\n#### Creating the tables\n\nLet’s create our tables in the DB. **In the _\\`createTable\\`_ command we can also pass our indexed fields, which will be used for \\`WHERE\\` and \\`ORDER BY\\` queries.**\n\nFor the \\`Patients\\` table we would like to query for patients using their emails or social security numbers. While for the \\`Exams\\` table we would like to find all records for a patient ordered by date entered in descending order.\n\n**_Keep in mind that this needs to happen once for your dApp._**\n\n```javascript\ntry {\n  await client.createTable('Patients'\n                          ['Email','SocialSecurityNumber']);\n  await client.createTable('Exams',\n                          ['PatientId', 'Date']);\n} catch (err) {\n  // will fail if the table is already created\n  console.error('Failed to create tables:', err.message);\n}\n```\n\nThis is so cool, you have your own DB in blockchain already. 🎉\n\n#### Inserting and updating records\n\nNow it’s time to start writing some data to our DB.\n\n```javascript\nconst updated = await client.insertObj('Patients', {\n  Id: 'pat-1000', // UNIQUE_PATIENT_ID\n  FirstName: 'Harry',\n  LastName: 'Kalogirou',\n  Email: 'harry@gmail.com',\n  SocialSecurityNumber: '1234567890',\n});\n// if patient exists\nif (updated) {\n  console.log('Patient has been updated:', err.message);\n}\nawait client.insertObj('Exams', {\n  Id: 1,\n  PatientId: 'pat-1000',\n  Date: '1257894000',\n  Info: '...',\n});\n```\n\n#### Reading records back\n\nAll good, our data is in the blockchain, how can we read it back. Let’s assume that we don’t know Patient’s Id, but only his email. And that we want to get his exams.\n\n```javascript\nconst patient = await client.get('Patients',\n                                 'Email == harry@ebakus.com');\nif (!patient) {\n  console.log('Failed to insert exam:', err.message);\n}\nconsole.log('Our patient:', patient);\nconst exams = client.select('Exams',\n                            \\`PatientId == ${patient.Id}\\`,\n                            'Date DESC');\nfor await (const exam of exams) {\n  console.log('Exam:', exam);\n}\n```\n\n#### Deleting records\n\nAll good, but we want to delete an exam. We can delete it, but keep in mind that what we write in the blockchain is immutable and we can’t remove it from the blockchains history.\n\n```javascript\nconst deleted = client.deleteObj('Exams', { Id: 1 });\n```\n\n#### Conclusions\n\nWithin this 2 pager walkthrough we covered the basic _CRUD_ operations on our database. Our goal of transparently using blockchain technology in our datastore is achieved. **We hope that simple, understandable and clean Javascript APIs to the datastore will enable new levels of blockchain secured infrastructure being deployed.** \n\nDevelopers can reuse their understanding of database systems and easily create new systems, and transition legacy databases to the new standard. \n\n**_With higher standards in data integrity and security already being in high demand, either by governments pressure, or by pure private sector maturing to understand the liabilities that our modern world and data management exposes them to, we expect legacy database systems to take the backseat in favour of blockchain enabled databases._** \n\n* * *\n\nMore articles are coming, with tutorials on how to use EbakusNG are coming so please make sure to follow me around in social media:\n\nTwitter: [https://twitter.com/harkal](https://twitter.com/harkal)\nMedium: [@harkal](https://medium.com/@harkal)\n\n_\\* EbakusNG is not to be confused with Ebakus which is based on my original work in blockchain tech. Since Ebakus was discontinued by its company after launching the public network in 2020, EbakusNG (next generation) embodies the next iteration of the software, and includes all advancements made since then._",
  "filePath": "src/content/blog/2020-11-25-integrating-blockchain-secured-data-with-node-js-and-ebakusng.md",
  "digest": "9557e7724c731d5f",
  "rendered": {
    "html": "<p>EbakusNG* is a next generation blockchain software that, among other things, can be used as <strong>a secure drop-in replacement for traditional databases.</strong></p>\n<p>Suppose you need a secure datastore for your application’s medical records. <strong>These are patient’s sensitive data, that need to be verifiably correct and secured across multiple clinics in a hospital and possibly securely and trustlessly shared with insurance companies.</strong> Let’s see how this can be implemented in a node.js application using EbakusNG as a blockchain enabled database.</p>\n<h4 id=\"installing-the-nodejslibrary\">Installing the node.js library</h4>\n<p>In order to use the EbakusDB through Node.js you first have to install the client library. For doing this you simply run:</p>\n<pre class=\"astro-code github-dark\" style=\"background-color:#24292e;color:#e1e4e8; overflow-x: auto;\" tabindex=\"0\" data-language=\"bash\"><code><span class=\"line\"><span style=\"color:#B392F0\">$</span><span style=\"color:#9ECBFF\"> npm</span><span style=\"color:#9ECBFF\"> install</span><span style=\"color:#9ECBFF\"> node-ebakusdb</span><span style=\"color:#79B8FF\"> --save</span></span></code></pre>\n<h4 id=\"defining-the-databaseschema\">Defining the database schema</h4>\n<p>Before continuing with the actual code and how to use the library, we have to define some models that we are going to use in our DB. For this post let’s use the following ones:</p>\n<pre class=\"astro-code github-dark\" style=\"background-color:#24292e;color:#e1e4e8; overflow-x: auto;\" tabindex=\"0\" data-language=\"javascript\"><code><span class=\"line\"><span style=\"color:#F97583\">const</span><span style=\"color:#79B8FF\"> schemas</span><span style=\"color:#F97583\"> =</span><span style=\"color:#E1E4E8\"> {</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  Patients: {</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    type: </span><span style=\"color:#9ECBFF\">'table'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    name: </span><span style=\"color:#9ECBFF\">'Patients'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    inputs: [</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">      { name: </span><span style=\"color:#9ECBFF\">'Id'</span><span style=\"color:#E1E4E8\">, type: </span><span style=\"color:#9ECBFF\">'string'</span><span style=\"color:#E1E4E8\"> },</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">      { name: </span><span style=\"color:#9ECBFF\">'FirstName'</span><span style=\"color:#E1E4E8\">, type: </span><span style=\"color:#9ECBFF\">'string'</span><span style=\"color:#E1E4E8\"> },</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">      { name: </span><span style=\"color:#9ECBFF\">'LastName'</span><span style=\"color:#E1E4E8\">, type: </span><span style=\"color:#9ECBFF\">'string'</span><span style=\"color:#E1E4E8\"> },</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">      { name: </span><span style=\"color:#9ECBFF\">'Email'</span><span style=\"color:#E1E4E8\">, type: </span><span style=\"color:#9ECBFF\">'string'</span><span style=\"color:#E1E4E8\"> },</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">      { name: </span><span style=\"color:#9ECBFF\">'SocialSecurityNumber'</span><span style=\"color:#E1E4E8\">, type: </span><span style=\"color:#9ECBFF\">'string'</span><span style=\"color:#E1E4E8\"> },</span></span>\n<span class=\"line\"><span style=\"color:#6A737D\">      // ...</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    ],</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  },</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  Exams: {</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    type: </span><span style=\"color:#9ECBFF\">'table'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    name: </span><span style=\"color:#9ECBFF\">'Exams'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    inputs: [</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">      { name: </span><span style=\"color:#9ECBFF\">'Id'</span><span style=\"color:#E1E4E8\">, type: </span><span style=\"color:#9ECBFF\">'string'</span><span style=\"color:#E1E4E8\"> },</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">      { name: </span><span style=\"color:#9ECBFF\">'PatientId'</span><span style=\"color:#E1E4E8\">, type: </span><span style=\"color:#9ECBFF\">'string'</span><span style=\"color:#E1E4E8\"> },</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">      { name: </span><span style=\"color:#9ECBFF\">'Date'</span><span style=\"color:#E1E4E8\">, type: </span><span style=\"color:#9ECBFF\">'uint64'</span><span style=\"color:#E1E4E8\"> },</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">      { name: </span><span style=\"color:#9ECBFF\">'Info'</span><span style=\"color:#E1E4E8\">, type: </span><span style=\"color:#9ECBFF\">'string'</span><span style=\"color:#E1E4E8\"> },</span></span>\n<span class=\"line\"><span style=\"color:#6A737D\">      // ...</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    ],</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  },</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}</span></span></code></pre>\n<p>The above schema describes two tables, one for <strong>Patients</strong> and one for <strong>medical exams</strong> they might have performed.</p>\n<h4 id=\"creating-our-connection-object\">Creating our connection object</h4>\n<p>Now that we have our models let’s create a client connection object.</p>\n<p><strong><em>For this type of application you might want to run private ebakus nodes deployed at various clinics. This is as easy to do as launching a mysql server, and we will cover this in a next tutorial. So stay tuned.</em></strong> </p>\n<pre class=\"astro-code github-dark\" style=\"background-color:#24292e;color:#e1e4e8; overflow-x: auto;\" tabindex=\"0\" data-language=\"javascript\"><code><span class=\"line\"><span style=\"color:#F97583\">const</span><span style=\"color:#79B8FF\"> ebakusdb</span><span style=\"color:#F97583\"> =</span><span style=\"color:#B392F0\"> require</span><span style=\"color:#E1E4E8\">(</span><span style=\"color:#9ECBFF\">'ebakusdb'</span><span style=\"color:#E1E4E8\">)</span></span>\n<span class=\"line\"><span style=\"color:#F97583\">const</span><span style=\"color:#79B8FF\"> client</span><span style=\"color:#F97583\"> =</span><span style=\"color:#E1E4E8\"> ebakusdb.</span><span style=\"color:#B392F0\">createClient</span><span style=\"color:#E1E4E8\">({</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  secure: </span><span style=\"color:#79B8FF\">true</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  host: </span><span style=\"color:#9ECBFF\">'rpc.ebakus-testnet.com'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  port: </span><span style=\"color:#79B8FF\">443</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  localSigning: </span><span style=\"color:#79B8FF\">true</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  keystoreV3: </span><span style=\"color:#9ECBFF\">'/examples/keystoreV3.json'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  keystoreV3Pass: </span><span style=\"color:#9ECBFF\">'123'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  schema: schemas </span><span style=\"color:#6A737D\">// as defined previously</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">})</span></span></code></pre>\n<p>So are we ready? In some sense, yes. You have a connection to a blockchain network that has a DB. You can now send commands to the database.</p>\n<h4 id=\"creating-thetables\">Creating the tables</h4>\n<p>Let’s create our tables in the DB. <strong>In the <em>`createTable`</em> command we can also pass our indexed fields, which will be used for `WHERE` and `ORDER BY` queries.</strong></p>\n<p>For the `Patients` table we would like to query for patients using their emails or social security numbers. While for the `Exams` table we would like to find all records for a patient ordered by date entered in descending order.</p>\n<p><strong><em>Keep in mind that this needs to happen once for your dApp.</em></strong></p>\n<pre class=\"astro-code github-dark\" style=\"background-color:#24292e;color:#e1e4e8; overflow-x: auto;\" tabindex=\"0\" data-language=\"javascript\"><code><span class=\"line\"><span style=\"color:#F97583\">try</span><span style=\"color:#E1E4E8\"> {</span></span>\n<span class=\"line\"><span style=\"color:#F97583\">  await</span><span style=\"color:#E1E4E8\"> client.</span><span style=\"color:#B392F0\">createTable</span><span style=\"color:#E1E4E8\">(</span><span style=\"color:#9ECBFF\">'Patients'</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">                          [</span><span style=\"color:#9ECBFF\">'Email'</span><span style=\"color:#E1E4E8\">,</span><span style=\"color:#9ECBFF\">'SocialSecurityNumber'</span><span style=\"color:#E1E4E8\">]);</span></span>\n<span class=\"line\"><span style=\"color:#F97583\">  await</span><span style=\"color:#E1E4E8\"> client.</span><span style=\"color:#B392F0\">createTable</span><span style=\"color:#E1E4E8\">(</span><span style=\"color:#9ECBFF\">'Exams'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">                          [</span><span style=\"color:#9ECBFF\">'PatientId'</span><span style=\"color:#E1E4E8\">, </span><span style=\"color:#9ECBFF\">'Date'</span><span style=\"color:#E1E4E8\">]);</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">} </span><span style=\"color:#F97583\">catch</span><span style=\"color:#E1E4E8\"> (err) {</span></span>\n<span class=\"line\"><span style=\"color:#6A737D\">  // will fail if the table is already created</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  console.</span><span style=\"color:#B392F0\">error</span><span style=\"color:#E1E4E8\">(</span><span style=\"color:#9ECBFF\">'Failed to create tables:'</span><span style=\"color:#E1E4E8\">, err.message);</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}</span></span></code></pre>\n<p>This is so cool, you have your own DB in blockchain already. 🎉</p>\n<h4 id=\"inserting-and-updatingrecords\">Inserting and updating records</h4>\n<p>Now it’s time to start writing some data to our DB.</p>\n<pre class=\"astro-code github-dark\" style=\"background-color:#24292e;color:#e1e4e8; overflow-x: auto;\" tabindex=\"0\" data-language=\"javascript\"><code><span class=\"line\"><span style=\"color:#F97583\">const</span><span style=\"color:#79B8FF\"> updated</span><span style=\"color:#F97583\"> =</span><span style=\"color:#F97583\"> await</span><span style=\"color:#E1E4E8\"> client.</span><span style=\"color:#B392F0\">insertObj</span><span style=\"color:#E1E4E8\">(</span><span style=\"color:#9ECBFF\">'Patients'</span><span style=\"color:#E1E4E8\">, {</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  Id: </span><span style=\"color:#9ECBFF\">'pat-1000'</span><span style=\"color:#E1E4E8\">, </span><span style=\"color:#6A737D\">// UNIQUE_PATIENT_ID</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  FirstName: </span><span style=\"color:#9ECBFF\">'Harry'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  LastName: </span><span style=\"color:#9ECBFF\">'Kalogirou'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  Email: </span><span style=\"color:#9ECBFF\">'harry@gmail.com'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  SocialSecurityNumber: </span><span style=\"color:#9ECBFF\">'1234567890'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">});</span></span>\n<span class=\"line\"><span style=\"color:#6A737D\">// if patient exists</span></span>\n<span class=\"line\"><span style=\"color:#F97583\">if</span><span style=\"color:#E1E4E8\"> (updated) {</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  console.</span><span style=\"color:#B392F0\">log</span><span style=\"color:#E1E4E8\">(</span><span style=\"color:#9ECBFF\">'Patient has been updated:'</span><span style=\"color:#E1E4E8\">, err.message);</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}</span></span>\n<span class=\"line\"><span style=\"color:#F97583\">await</span><span style=\"color:#E1E4E8\"> client.</span><span style=\"color:#B392F0\">insertObj</span><span style=\"color:#E1E4E8\">(</span><span style=\"color:#9ECBFF\">'Exams'</span><span style=\"color:#E1E4E8\">, {</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  Id: </span><span style=\"color:#79B8FF\">1</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  PatientId: </span><span style=\"color:#9ECBFF\">'pat-1000'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  Date: </span><span style=\"color:#9ECBFF\">'1257894000'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  Info: </span><span style=\"color:#9ECBFF\">'...'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">});</span></span></code></pre>\n<h4 id=\"reading-recordsback\">Reading records back</h4>\n<p>All good, our data is in the blockchain, how can we read it back. Let’s assume that we don’t know Patient’s Id, but only his email. And that we want to get his exams.</p>\n<pre class=\"astro-code github-dark\" style=\"background-color:#24292e;color:#e1e4e8; overflow-x: auto;\" tabindex=\"0\" data-language=\"javascript\"><code><span class=\"line\"><span style=\"color:#F97583\">const</span><span style=\"color:#79B8FF\"> patient</span><span style=\"color:#F97583\"> =</span><span style=\"color:#F97583\"> await</span><span style=\"color:#E1E4E8\"> client.</span><span style=\"color:#B392F0\">get</span><span style=\"color:#E1E4E8\">(</span><span style=\"color:#9ECBFF\">'Patients'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">                                 'Email == harry@ebakus.com'</span><span style=\"color:#E1E4E8\">);</span></span>\n<span class=\"line\"><span style=\"color:#F97583\">if</span><span style=\"color:#E1E4E8\"> (</span><span style=\"color:#F97583\">!</span><span style=\"color:#E1E4E8\">patient) {</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  console.</span><span style=\"color:#B392F0\">log</span><span style=\"color:#E1E4E8\">(</span><span style=\"color:#9ECBFF\">'Failed to insert exam:'</span><span style=\"color:#E1E4E8\">, err.message);</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">console.</span><span style=\"color:#B392F0\">log</span><span style=\"color:#E1E4E8\">(</span><span style=\"color:#9ECBFF\">'Our patient:'</span><span style=\"color:#E1E4E8\">, patient);</span></span>\n<span class=\"line\"><span style=\"color:#F97583\">const</span><span style=\"color:#79B8FF\"> exams</span><span style=\"color:#F97583\"> =</span><span style=\"color:#E1E4E8\"> client.</span><span style=\"color:#B392F0\">select</span><span style=\"color:#E1E4E8\">(</span><span style=\"color:#9ECBFF\">'Exams'</span><span style=\"color:#E1E4E8\">,</span></span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">                            \\</span><span style=\"color:#9ECBFF\">`PatientId == ${</span><span style=\"color:#E1E4E8\">patient</span><span style=\"color:#9ECBFF\">.</span><span style=\"color:#E1E4E8\">Id</span><span style=\"color:#9ECBFF\">}</span><span style=\"color:#79B8FF\">\\`</span><span style=\"color:#9ECBFF\">,</span></span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">                            'Date DESC');</span></span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">for await (const exam of exams) {</span></span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">  console.log('Exam:', exam);</span></span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">}</span></span></code></pre>\n<h4 id=\"deleting-records\">Deleting records</h4>\n<p>All good, but we want to delete an exam. We can delete it, but keep in mind that what we write in the blockchain is immutable and we can’t remove it from the blockchains history.</p>\n<pre class=\"astro-code github-dark\" style=\"background-color:#24292e;color:#e1e4e8; overflow-x: auto;\" tabindex=\"0\" data-language=\"javascript\"><code><span class=\"line\"><span style=\"color:#F97583\">const</span><span style=\"color:#79B8FF\"> deleted</span><span style=\"color:#F97583\"> =</span><span style=\"color:#E1E4E8\"> client.</span><span style=\"color:#B392F0\">deleteObj</span><span style=\"color:#E1E4E8\">(</span><span style=\"color:#9ECBFF\">'Exams'</span><span style=\"color:#E1E4E8\">, { Id: </span><span style=\"color:#79B8FF\">1</span><span style=\"color:#E1E4E8\"> });</span></span></code></pre>\n<h4 id=\"conclusions\">Conclusions</h4>\n<p>Within this 2 pager walkthrough we covered the basic <em>CRUD</em> operations on our database. Our goal of transparently using blockchain technology in our datastore is achieved. <strong>We hope that simple, understandable and clean Javascript APIs to the datastore will enable new levels of blockchain secured infrastructure being deployed.</strong> </p>\n<p>Developers can reuse their understanding of database systems and easily create new systems, and transition legacy databases to the new standard. </p>\n<p><strong><em>With higher standards in data integrity and security already being in high demand, either by governments pressure, or by pure private sector maturing to understand the liabilities that our modern world and data management exposes them to, we expect legacy database systems to take the backseat in favour of blockchain enabled databases.</em></strong> </p>\n<hr>\n<p>More articles are coming, with tutorials on how to use EbakusNG are coming so please make sure to follow me around in social media:</p>\n<p>Twitter: <a href=\"https://twitter.com/harkal\">https://twitter.com/harkal</a>\nMedium: <a href=\"https://medium.com/@harkal\">@harkal</a></p>\n<p><em>* EbakusNG is not to be confused with Ebakus which is based on my original work in blockchain tech. Since Ebakus was discontinued by its company after launching the public network in 2020, EbakusNG (next generation) embodies the next iteration of the software, and includes all advancements made since then.</em></p>",
    "metadata": {
      "headings": [
        {
          "depth": 4,
          "slug": "installing-the-nodejslibrary",
          "text": "Installing the node.js library"
        },
        {
          "depth": 4,
          "slug": "defining-the-databaseschema",
          "text": "Defining the database schema"
        },
        {
          "depth": 4,
          "slug": "creating-our-connection-object",
          "text": "Creating our connection object"
        },
        {
          "depth": 4,
          "slug": "creating-thetables",
          "text": "Creating the tables"
        },
        {
          "depth": 4,
          "slug": "inserting-and-updatingrecords",
          "text": "Inserting and updating records"
        },
        {
          "depth": 4,
          "slug": "reading-recordsback",
          "text": "Reading records back"
        },
        {
          "depth": 4,
          "slug": "deleting-records",
          "text": "Deleting records"
        },
        {
          "depth": 4,
          "slug": "conclusions",
          "text": "Conclusions"
        }
      ],
      "localImagePaths": [],
      "remoteImagePaths": [],
      "frontmatter": {
        "title": "Integrating Blockchain secured data with node.js and EbakusNG",
        "description": "",
        "pubDate": "2020-11-25T11:41:52.000Z",
        "author": "HarKal",
        "categories": [
          "Uncategorized"
        ],
        "tags": [
          "blockchain",
          "databases",
          "software"
        ],
        "wordpressUrl": "https://kalogirou.net/2020/11/25/integrating-blockchain-secured-data-with-node-js-and-ebakusng/"
      },
      "imagePaths": []
    }
  },
  "collection": "blog"
}