<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ulises Avila</title>
    <description>The latest articles on DEV Community by Ulises Avila (@ulisesac4).</description>
    <link>https://dev.to/ulisesac4</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F590599%2Fc30c5482-dc7f-46be-9e5d-5088feac45fc.jpg</url>
      <title>DEV Community: Ulises Avila</title>
      <link>https://dev.to/ulisesac4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ulisesac4"/>
    <language>en</language>
    <item>
      <title>Speaking is more joyful than writing</title>
      <dc:creator>Ulises Avila</dc:creator>
      <pubDate>Mon, 25 Apr 2022 00:00:00 +0000</pubDate>
      <link>https://dev.to/ulisesac4/speaking-is-more-joyful-than-writing-1l86</link>
      <guid>https://dev.to/ulisesac4/speaking-is-more-joyful-than-writing-1l86</guid>
      <description>&lt;p&gt;I remember my high school days when I used to write some reports using Dragon Neutral Speaking software I do not understand why I didn't continue doing that.&lt;/p&gt;

&lt;p&gt;Because now I'm having the same creative blockage that many people have. This problem is famous, you know it, and you may have suffered from it.&lt;/p&gt;

&lt;p&gt;You have a topic to write about and even though you have the overall structure of your posting you don't have ideas coming to you, and this problem is exacerbated because you enter into a loop that doesn't let you work. No idea comes to you, staring at the white space of your monitor stresses you back, then you force yourself to write something but again nothing comes to mind, and when you finally have something to write then suddenly the flow of the ideas stops, and then you get into the loop again.&lt;/p&gt;

&lt;p&gt;This situation blinds us to the real problem and it is that we are not used to expressing ourselves. Making your ideas come to you is also a skill that has to be developed, and forcing us to write is hindering us from improving such skill&lt;/p&gt;

&lt;p&gt;This is why I think that speech-to-text technologies come into play as I said in my introduction paragraph, I used to use one to write some reports and now I don't use it anymore I don't even know what is the reason behind this. But today I get the realization that now I have the same opportunity but now inside a smartphone. This pushes me to again start writing some ideas, but now those ideas are not going to come from my fingers if not from my mouth.&lt;/p&gt;

&lt;p&gt;This posting here is done fully by speech-to-text technologies I also need to train my idea eloquence fluency, not just my fluency in using a foreign language. This also helps to develop speech skills and my elaboration of texts too.&lt;/p&gt;

&lt;p&gt;So this is more a text to tell you that if you aren't writing the old-fashioned way. Do not distress yourself over word count typing because that will be a hassle to your thought process and if you start to dictate your ideas, also do not get distressed on the maximum words per minute that speaking will supposedly give you unless you already have the text word by word in your mind, you won't benefit of the primary speed that speech gives you.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Cyphraium, an effort of overengineering that came true</title>
      <dc:creator>Ulises Avila</dc:creator>
      <pubDate>Fri, 22 Apr 2022 00:00:00 +0000</pubDate>
      <link>https://dev.to/ulisesac4/cyphraium-an-effort-of-overengineering-that-came-true-2ohn</link>
      <guid>https://dev.to/ulisesac4/cyphraium-an-effort-of-overengineering-that-came-true-2ohn</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Have you ever had &lt;code&gt;The Idea&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;That idea that will grow into a big successful business? You meditate on it, and after some time you manage to control your excitement over it so you can think about the pros and cons.&lt;/p&gt;

&lt;p&gt;Suddenly, you are ready to start your idea in motion. But that's the tricky part, an idea is just that, an idea. You still lack execution.&lt;/p&gt;

&lt;p&gt;The idea is just a newsletter, a newsletter about crypto, after all, you like reading news about it, so you want to share them with a possible audience similar to you.&lt;/p&gt;

&lt;p&gt;So, what are you going to do? There is Revue, you can just open it by linking your Twitter account.&lt;/p&gt;

&lt;p&gt;But you do not want to link your small audience in your account to this exact topic.&lt;/p&gt;

&lt;p&gt;There is also the idea of just giving away a Google Form to collect emails and send them manually to the newsletter. But that is too raw. And absolutely reject the idea of managing a newsletter that way.&lt;/p&gt;

&lt;p&gt;Another option is using Email Delivery Services. The first names you remember are Sendgrid, Mailchimp, and Mailgun. And at this point, you remember that some of them offer email templating services and marketing automation so I can deal with my newsletter. But you still feel that you want a little bit of control in the lifecycle of creating and delivering the newsletter.&lt;/p&gt;

&lt;p&gt;You start designing it. It is just a &lt;em&gt;simple&lt;/em&gt; Rest API that schedules future newsletters, sends them at the right time, and &lt;em&gt;triggers&lt;/em&gt; the building of a website if You decide to have it too.&lt;/p&gt;

&lt;p&gt;You could build it in a matter of hours using your skills. A little bit of Nodejs, Sequelize for connecting to the database and the npm package of the chosen email service.&lt;/p&gt;

&lt;p&gt;This is where things start to complicate, even though I can agree that things got more difficult the moment You decided to back this up with an Api.&lt;/p&gt;

&lt;p&gt;In your defense. You want to have an organized place where You can store your newsletters. This points you to choose Sqlite for this purpose. You have a file where the data resides and if a problem arises You just need to move it around.&lt;/p&gt;

&lt;p&gt;After this, comes the question. Is a front website needed? You decide that you want it, you could have a newsletter that only sends emails, but you like the idea of having a public reservoir for the newsletter.&lt;/p&gt;

&lt;p&gt;So it is decided, and you choose Gatsby for it, many will question you as fast as a bullet asking you why you did not choose Next.js, but you know it, because, at least at the moment you met Next.js and you understood that it also can be used for generating Static Sites, there &lt;em&gt;wasn't a simple way&lt;/em&gt; to deal with &lt;em&gt;simple&lt;/em&gt; things like ordering content without hitting a server that does for you. And the most important thing is that you do not want to &lt;em&gt;deal with the complexity&lt;/em&gt; of learning another tool that at this moment you do not know if this can satisfy your necessity.&lt;/p&gt;

&lt;p&gt;Then, you start to look for the Api of Netlify to see how you can trigger a rebuild for the moment an issue goes live. This is because you know how heavy is to do it in a small server and then send it to the production place.&lt;/p&gt;

&lt;p&gt;And it is easier than thought. Netlify has something called &lt;code&gt;Build Hooks&lt;/code&gt; that are just &lt;em&gt;private&lt;/em&gt; URLs that you just need to make a post request to and the build will trigger.&lt;/p&gt;

&lt;p&gt;But now comes the hardest part. What server tech are you going to choose? One of the purposes of managing the content with a self-made Rest Api, is just to practice the process of building it, and you also want to start to use Elixir, so it is settled. The backend is done in Phoenix framework.&lt;/p&gt;

&lt;p&gt;You choose Mailchimp because it feels like the perfect compromise between all the researched options.&lt;/p&gt;

&lt;p&gt;And then the server is done, with some problems of course, after all, everything that you can do in a Javascript environment is not something that you know right away in Elixir. But the learnings are welcome. Now you can do almost everything you know about Rest Apis in Elixir. The server publishes the newsletter, triggers a rebuild of a frontend, and even it has Xml feeds. You can even schedule content to be published on future dates.&lt;/p&gt;

&lt;p&gt;You feel great, this is where the adventure of growing starts.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;If you liked this reading you are free to check the resulting website at https://cyphraium.com/newsletter, and if you also like crypto as much as I like, I invite you to subscribe to it.&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Comparing dates in Elixir</title>
      <dc:creator>Ulises Avila</dc:creator>
      <pubDate>Fri, 08 Apr 2022 00:00:00 +0000</pubDate>
      <link>https://dev.to/ulisesac4/comparing-dates-in-elixir-20df</link>
      <guid>https://dev.to/ulisesac4/comparing-dates-in-elixir-20df</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Comparing dates is a common procedure in day to day jobs. Whether you need them to trigger future, or past jobs you will need to know how to do it in Elixir.&lt;/p&gt;

&lt;h3&gt;
  
  
  Contents
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
Introduction

&lt;ul&gt;
&lt;li&gt;Contents&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Requirements&lt;/li&gt;
&lt;li&gt;
Comparing Dates

&lt;ul&gt;
&lt;li&gt;Example 1&lt;/li&gt;
&lt;li&gt;Example 2&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;After thoughts&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;none&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Comparing Dates
&lt;/h2&gt;

&lt;p&gt;To acomplish this task, you will use the &lt;code&gt;.compare/2&lt;/code&gt; method. Which exists in both &lt;code&gt;Date&lt;/code&gt; and &lt;code&gt;DateTime&lt;/code&gt; structs.&lt;/p&gt;

&lt;p&gt;Upon success compare, the method will return any of the next atoms &lt;code&gt;:lt | :eq | :gt&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example 1
&lt;/h4&gt;

&lt;p&gt;A &lt;code&gt;DateTime&lt;/code&gt; utc format comparison where the first element is greater than the second.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iex(5)&amp;gt; DateTime.compare(~U[2022-04-10 04:51:27.626455Z], ~U[2022-03-10 04:51:27.626455Z])
:gt

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Example 2
&lt;/h4&gt;

&lt;p&gt;A &lt;code&gt;Date&lt;/code&gt; comparison where the first element is lesser than the second.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iex(2)&amp;gt; Date.compare(~D[2022-04-01], ~D[2022-04-08])
:lt

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  After thoughts
&lt;/h2&gt;

&lt;p&gt;After using other tools in differents environments like &lt;code&gt;date-fns&lt;/code&gt; or &lt;code&gt;moment&lt;/code&gt; in javascript. I find refreshing the method used in this posting, instead of relying on a specific method to assert a question, ie &lt;code&gt;isAfter&lt;/code&gt; from &lt;code&gt;date-fns&lt;/code&gt;, here you get exactly the result of the comparison.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Backing up data in RethinkDB</title>
      <dc:creator>Ulises Avila</dc:creator>
      <pubDate>Thu, 25 Oct 2018 00:00:00 +0000</pubDate>
      <link>https://dev.to/ulisesac4/backing-up-data-in-rethinkdb-5hln</link>
      <guid>https://dev.to/ulisesac4/backing-up-data-in-rethinkdb-5hln</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;One recurrent task for database administrators is creating and applying back ups. In this tutorial you will learn how to do this task in a RethinkDB environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Requeriments
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A running installation of RethinkdB.&lt;/li&gt;
&lt;li&gt;The python package &lt;code&gt;rethinkdb&lt;/code&gt; installed to your machine with &lt;code&gt;pip&lt;/code&gt;. The &lt;code&gt;import&lt;/code&gt; tool is bundled in that package. It is recommended to use the Python 3 version package, as Python 2 is reaching its end of life soon.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setting up your data
&lt;/h2&gt;

&lt;p&gt;Before creating a backup it is important to setting up the RethinkDB server, just do this steps quickly:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your Web Panel, it is located at &lt;code&gt;localhost:8080&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Go to the &lt;code&gt;Tables&lt;/code&gt; section and add a database named &lt;code&gt;FinancialXchanges&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In the database &lt;code&gt;FinancialXchanges&lt;/code&gt; create a table named &lt;code&gt;Dollar&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now go to the &lt;code&gt;Data Explorer&lt;/code&gt; section and run the following query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;r.db('FinancialXchanges').table('Dollar').insert( [
{
"week": 26, "id": 1, "cad": 1.28837, "jpy": 109.89
},
{
"week": 27, "id": 2, "cad": 1.30979, "jpy": 109.89
},
{
"week": 28, "id": 3, "cad": 1.25588, "jpy": 106.751
},
{
"week": 29, "id": 4, "cad": 1.2483, "jpy": 104.709
},
{
"week": 30, "id": 5, "cad": 1.27785, "jpy": 108.165
},
{
"week": 31, "id": 6, "cad": 1.27459, "jpy": 107.137
},
{
"week": 32, "id": 7, "cad": 1.26657, "jpy": 108.987
}
] )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have the required data to follow this tutorial&lt;/p&gt;

&lt;h2&gt;
  
  
  Doing a backup
&lt;/h2&gt;

&lt;p&gt;The command to create a backup is &lt;code&gt;dump&lt;/code&gt;, by default it does a backup of all the server. To limit its scope use the &lt;code&gt;-e&lt;/code&gt; option, you can choose the name of the backup with the &lt;code&gt;-f&lt;/code&gt; option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rethinkdb dump -e FinancialXchanges.Dollar -f backup1.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Such file will be stored in your actual folder in your terminal session, you can &lt;code&gt;ls&lt;/code&gt; to see your backup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;YOUR_USER@YOUR_DOMAIN:~# ls
backup1.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this go to your Web Panel and erase the &lt;code&gt;FinancialXchanges&lt;/code&gt; database because you are going to restore in the next section.&lt;/p&gt;

&lt;h2&gt;
  
  
  Restoring a backup
&lt;/h2&gt;

&lt;p&gt;The tool to restore a backup is &lt;code&gt;restore&lt;/code&gt;. Restore is a powerful tool that let us apply backups over secure tunnels for example or even point to a specific database and table. In your case you only backed up one simple database so you can run the clean command without any extra options:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rethinkdb restore backup1.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;RethinkDB will tell you the amount of data imported to your server.&lt;/p&gt;

&lt;p&gt;To settle things up, run this query in the &lt;code&gt;Data Explorer&lt;/code&gt; section in the Web panel to list the contents of your restored table and database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;r.db('FinancialXchanges').table('Dollar')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should be able to see the original data that you created steps before.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;As you saw managing back ups in RethinkDb is fairly easy. After this tutorial it is recommended to play with the different options of both &lt;code&gt;dump&lt;/code&gt; and &lt;code&gt;retore&lt;/code&gt; commands, so you can understand the different options that those command can offer to you.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Importing data in RethinkDB</title>
      <dc:creator>Ulises Avila</dc:creator>
      <pubDate>Sat, 20 Oct 2018 00:00:00 +0000</pubDate>
      <link>https://dev.to/ulisesac4/importing-data-in-rethinkdb-4ijb</link>
      <guid>https://dev.to/ulisesac4/importing-data-in-rethinkdb-4ijb</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;There will be moments in which you need to move around your data between different database softwares. Fortunately RethinkDB can take data from JSON and CSV files exported from other services as MySQL or PostgreSQL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Requeriments
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A running RethinkDB installation.&lt;/li&gt;
&lt;li&gt;The python package &lt;code&gt;rethinkdb&lt;/code&gt; installed to your machine with &lt;code&gt;pip&lt;/code&gt;. The &lt;code&gt;import&lt;/code&gt; tool to perform data importing is bundled in that package. It is recommended to use the Python 3 version package, as Python 2 is reaching its end of life soon.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Preparing the data
&lt;/h2&gt;

&lt;p&gt;For this tutorial you will need two files, one &lt;code&gt;json&lt;/code&gt; and one &lt;code&gt;csv&lt;/code&gt;. Preferably placed in your &lt;code&gt;home&lt;/code&gt; folder. Something important to note is that you do not need to already have created your destination table because RethinkDB takes care of it.&lt;/p&gt;

&lt;p&gt;The first file is called &lt;code&gt;temp_data1.json&lt;/code&gt;, and should contain the following contents:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  {
    "id": 1, "day": "monday", "max": 23, "min": 12
  },
  {
    "id": 2, "day": "tuesday", "max": 22, "min": 12
  },
  {
    "id": 3, "day": "wednesday", "max": 23, "min": 12
  },
  {
    "id": 4, "day": "thursday", "max": 24, "min": 12
  },
  {
    "id": 5, "day": "friday", "max": 25, "min": 12
  },
  {
    "id": 6, "day": "saturday", "max": 26, "min": 13
  },
  {
    "id": 7, "day": "sunday", "max": 27, "min": 13
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the second one is called &lt;code&gt;temp_data2.csv&lt;/code&gt; with the following contents:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;id, day, max, min
8, 'monday', 24, 12
9, 'tuesday', 21, 11
10, 'wednesday', 26, 14
11, 'thursday', 24, 13
12, 'friday', 25, 12
13, 'saturday', 25, 10
14, 'sunday', 22, 14
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that it is recommended to use commas as separators for the second file. Also check that you have your RethinkDB instance running in the way you are more confortable with.&lt;/p&gt;

&lt;h2&gt;
  
  
  Importing the JSON file
&lt;/h2&gt;

&lt;p&gt;After having created the files you are ready to import data. You will use the &lt;code&gt;import&lt;/code&gt; command of RethinkDB with the name of the file and the name of the table where data will be stored. In this case data is going to be in &lt;code&gt;test&lt;/code&gt; database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rethinkdb import -f temp_data1.json --table test.TempData1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you will get a message with the amount of rows imported to your table.&lt;/p&gt;

&lt;h2&gt;
  
  
  Importing the CSV file
&lt;/h2&gt;

&lt;p&gt;Importing a CSV file is just as easy as importing a JSON file, you just have to specify the file format with the &lt;code&gt;--format&lt;/code&gt; option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rethinkdb import -f temp_data2.csv --table test.TempData2 --format csv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again, you will get the amount of rows imported to your table. Note that this time you are importing to different table.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping things up
&lt;/h2&gt;

&lt;p&gt;After having success importing data to your database, it is time to query it so you can see it. Run each command separately in the Web Panel located at &lt;code&gt;localhost:8080&lt;/code&gt; in the &lt;code&gt;Data Explorer&lt;/code&gt; section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;r.db('test').table('TempData1')
r.db('test').table('TempData2')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is difference between both queries' result, everything in a CSV is imported as string, you must either convert the already imported data in RethinkDB or transform the CSV to JSON with specialized tools.&lt;/p&gt;

&lt;p&gt;To finish this part keep in mind that in the case you already created the destination tables in the database just add the &lt;code&gt;--force&lt;/code&gt; option to your command to force data writing to those tables.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;RethinkDB provides a fast and useful tool for importing data. Fortunately for us, the tools used in this tutorial can be automated with the help of programming languages and its respective bindings. With this we can incorporate data from external service in a breeze.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Administrating users in RethinkDB</title>
      <dc:creator>Ulises Avila</dc:creator>
      <pubDate>Mon, 15 Oct 2018 00:00:00 +0000</pubDate>
      <link>https://dev.to/ulisesac4/administrating-users-in-rethinkdb-1nl6</link>
      <guid>https://dev.to/ulisesac4/administrating-users-in-rethinkdb-1nl6</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;When managing databases, one is in the need to configure mechanisms of authentication which can extend to authorization mechanisms. RethinkDB has a plain simple users mechanism to control user creation, permissions given and scope of action.&lt;/p&gt;

&lt;p&gt;In this tutorial you will apply several configurations of permissions to three different users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Requeriments
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Have one server with RethinkDB running.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setting things up
&lt;/h2&gt;

&lt;p&gt;This administrative task is done via web panel. So after ssh login to your dopplet run &lt;code&gt;rethinkdb&lt;/code&gt; or &lt;code&gt;rethinkdb --bind all&lt;/code&gt; depending if you are tunneling or not so you can access your panel via &lt;code&gt;domain_name:8080&lt;/code&gt; or &lt;code&gt;dopplet_url:8080&lt;/code&gt;. Everything is done in the &lt;code&gt;Data Explorer&lt;/code&gt; section placed in the navbar.&lt;/p&gt;

&lt;p&gt;RethinkDB makes you the &lt;code&gt;admin&lt;/code&gt; user when accessing it via web panel, so you have total control of the node.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding users
&lt;/h3&gt;

&lt;p&gt;To avoid confusion between examples we are going to have several users, one per example. Users are stored in the table &lt;code&gt;users&lt;/code&gt; in the &lt;code&gt;rethinkdb&lt;/code&gt; database. To create them you use the &lt;code&gt;insert&lt;/code&gt; function passing a JSON object, to finish this step you are going to pass a JSON array of 3 members like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;r.db('rethinkdb').table('users').insert([
    {id: 'john', password: 'pass1'},
    {id: 'jack', password: 'pass2'},
    {id: 'joe', password: 'pass3'},
    ])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything went ok, you will get as response an object like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "deleted": 0 ,
    "errors": 0 ,
    "inserted": 3 ,
    "replaced": 0 ,
    "skipped": 0 ,
    "unchanged": 0
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is important to note that once created you cannot modify the &lt;code&gt;id&lt;/code&gt; of the users, you have to delete the entire user so you can add it again with the desired name.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding tables
&lt;/h3&gt;

&lt;p&gt;To encapsulate the tests you are adding two tables into &lt;code&gt;test&lt;/code&gt; database, &lt;code&gt;CompactCameras&lt;/code&gt; and &lt;code&gt;DslrCameras&lt;/code&gt;, you are executing two times the create method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;r.db('test').tableCreate('CompactCameras')
r.db('test').tableCreate('DslrCameras')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything went fine, you will get as response one medium sized JSON object telling you the details of each table.&lt;/p&gt;

&lt;p&gt;With this you are ready to jump to the examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 1
&lt;/h2&gt;

&lt;p&gt;In this example &lt;code&gt;john&lt;/code&gt; gets to read and write from the table &lt;code&gt;CompactCameras&lt;/code&gt; with the help of the &lt;code&gt;grant&lt;/code&gt; method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;r.db('test').table('CompactCameras').grant('john', {read: true, write: true});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After executing this command you will get an answer like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"granted": 1 ,
"permissions_changes": [
    {
        "new_val": {
            "read": true ,
            "write": true
        } ,
        "old_val": null
    }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is telling that permissions have gotten changes. It is also reporting the state of the configuration between &lt;code&gt;old_val&lt;/code&gt; and &lt;code&gt;new_val&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There is not anything left to do for configuring permission to this user, you could go and use this user in your application's authentication and everything would be working. Now you can review the second example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 2
&lt;/h2&gt;

&lt;p&gt;In this example &lt;code&gt;jack&lt;/code&gt; gets to read and write from the table &lt;code&gt;CompactCameras&lt;/code&gt; and read from &lt;code&gt;DslrCameras&lt;/code&gt;, seeing the last example you can infer that you have to execute the command two times,each for every table to modify:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;r.db('test').table('CompactCameras').grant('jack', {read: true, write: true});
r.db('test').table('DslrCameras').grant('jack', {read: true});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will get one response as the one from example 1 telling you the changes that have been done. The important thing in this example is that one user can have active permissions on different elements at the same time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 3
&lt;/h2&gt;

&lt;p&gt;In this example &lt;code&gt;joe&lt;/code&gt; gets access to all configurations of &lt;code&gt;test&lt;/code&gt; database with the exception of &lt;code&gt;DslrCameras&lt;/code&gt;, again you have to execute each command separately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;r.db('test').grant('joe', {read: true, write: true});
r.db('test').table('DslrCameras').grant('joe', {read: false, write: false});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first thing to note in this example is that the &lt;code&gt;grant&lt;/code&gt; command can be applied to any level of the structure, where the levels are: &lt;code&gt;r&lt;/code&gt; as all the database, &lt;code&gt;r.db&lt;/code&gt; as one database and &lt;code&gt;r.db.table&lt;/code&gt; as one table in one database.&lt;/p&gt;

&lt;p&gt;The second thing to note is that permissions in broader scopes get inherited to smaller scopes, using example 3 for this leads to say that &lt;code&gt;joe&lt;/code&gt; have read and write access to any element in &lt;code&gt;test&lt;/code&gt; database until it is specified that he cannot do it in the table &lt;code&gt;DslrCameras&lt;/code&gt;. There is one example left.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 4
&lt;/h2&gt;

&lt;p&gt;Any global permission must be written directly to &lt;code&gt;r&lt;/code&gt; such as letting &lt;code&gt;joe&lt;/code&gt; full access to the server with the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;r.grant('joe', {read: true, write: true, config: true, connect: true});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last thing to note is that the &lt;code&gt;connect&lt;/code&gt; option is only eligible for global scope.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;When a user is added it does not have any permissions, but you can set values with the &lt;code&gt;grant&lt;/code&gt; method, after that permissions not set are considered as false. The simplicity of RethinkDB does not let us to login to the admin panel as any of the users created in this tutorial, then the next step would be to create an app that connects to your server so you can test your user permissions. You can go and check the official RethinkDB and see the offering of drivers for your programming language of choice.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Installing RethinkDB</title>
      <dc:creator>Ulises Avila</dc:creator>
      <pubDate>Sat, 15 Sep 2018 00:00:00 +0000</pubDate>
      <link>https://dev.to/ulisesac4/installing-rethinkdb-34ff</link>
      <guid>https://dev.to/ulisesac4/installing-rethinkdb-34ff</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;RethinkDB is a database engine of the family of schemaless NoSQL systems. It is known as the database for the real time web because it lets you suscribe to a feed of data, so every time you make a change to the database you get as result a cursor with the new data. It uses JSON data to store information like MongoDB.&lt;/p&gt;

&lt;p&gt;In this tutorial you will install RethinkDB in one of your servers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;p&gt;Have one server with any of the following OS: Centos, Debian, Fedora, Ubuntu.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;RethinkDB is not in the official repos of the distros listed in the last part. So you must add the repo for the matching platform you are using. Keep in mind that you can build it form source and then install it, but it can become burdensome in the long run.&lt;/p&gt;

&lt;h3&gt;
  
  
  Centos
&lt;/h3&gt;

&lt;p&gt;To add the repo in Centos just copy and paste the next command, watch OS_VERSION because it must match the version of Centos you are using. Currently the supported versions are 6 and 7:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo wget http://download.rethinkdb.com/centos/OS_VERSION/`uname -m`/rethinkdb.repo -O /etc/yum.repos.d/rethinkdb.repo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you can install it with yum:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum install rethinkdb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Debian
&lt;/h3&gt;

&lt;p&gt;For Debian be sure to use Wheezy or Jessie distros because the binaries are built for them. Then you can execute both commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "deb http://download.rethinkdb.com/apt `lsb_release -cs` main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then update your repos and install the package:&lt;/p&gt;

&lt;p&gt;sudo apt-get update &amp;amp;&amp;amp; apt-get install rethinkdb&lt;/p&gt;

&lt;h3&gt;
  
  
  Fedora
&lt;/h3&gt;

&lt;p&gt;There is not official package built for Fedora, but the Centos package works fine, it is recommended to use the Centos 6 repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo wget http://download.rethinkdb.com/centos/6/`uname -m`/rethinkdb.repo -O /etc/yum.repos.d/rethinkdb.repo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now use yum afterwards:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum install rethinkdb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Ubuntu
&lt;/h3&gt;

&lt;p&gt;You can install RethinkDB in Ubuntu as long as your system version is 12.04 or older. As in the Debian version execute both commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source /etc/lsb-release &amp;amp;&amp;amp; echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally update repos and install the package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get update &amp;amp;&amp;amp; apt-get install rethinkdb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Starting up the server
&lt;/h2&gt;

&lt;p&gt;Almost all your admin tasks will be done over a web panel, to access it you just go to &lt;code&gt;localhost:8080&lt;/code&gt;, but RethinkDB does not start automatically after installation. You have to start it using &lt;code&gt;rethinkdb&lt;/code&gt; and you will have the session open in you command line. You can expose it to all network traffic with the &lt;code&gt;rethinkdb --bind all&lt;/code&gt;, in this way you can access it from your remote host, but keep in mind that this is insecure because the panel would be open to the internet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Follow up
&lt;/h2&gt;

&lt;p&gt;Installing RethinkDB is just as easy as booting up a distro, starting up the service is easy too. But this service is not persistent, after this tutorial you should go and read how to configure a systemd unit service to &lt;code&gt;enable&lt;/code&gt; and &lt;code&gt;start&lt;/code&gt; a RethinkDB installation.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
