<?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: Sulaiman Aminu Barkindo</title>
    <description>The latest articles on DEV Community by Sulaiman Aminu Barkindo (@sulaimanaminubarkindo).</description>
    <link>https://dev.to/sulaimanaminubarkindo</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%2F924478%2F92c81c50-fc41-4c19-add7-1de98f7f4969.jpeg</url>
      <title>DEV Community: Sulaiman Aminu Barkindo</title>
      <link>https://dev.to/sulaimanaminubarkindo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sulaimanaminubarkindo"/>
    <language>en</language>
    <item>
      <title>C Program for Prime Number Using Recursion</title>
      <dc:creator>Sulaiman Aminu Barkindo</dc:creator>
      <pubDate>Thu, 06 Oct 2022 03:32:27 +0000</pubDate>
      <link>https://dev.to/sulaimanaminubarkindo/c-program-for-prime-number-using-recursion-2ij4</link>
      <guid>https://dev.to/sulaimanaminubarkindo/c-program-for-prime-number-using-recursion-2ij4</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Prime number is a number that is greater than 1 and can be divided only by 1 or itself. In other words, prime numbers can't be divided by numbers other than itself or 1. Example of prime numbers are 2, 3, 5, 7, 11, ...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;br&gt;
I made the implementation in two functions to aid readability.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
 * is_prime - detects if an input number is a prime number.
 * @n: input number.
 * @i: iterator.
 * Return: 1 if n is a prime number. 0 if n is not a prime number.
 */
int is_prime(unsigned int n, unsigned int i)
{
        if (n % i == 0)
        {
                if (n == i)
                        return (1);
                else
                        return (0);
        }
        return (0 + is_prime(n, i + 1));
}
/**
 * is_prime_number - detects if an input number is a prime number.
 * @n: input number.
 * Return: 1 if n is a prime number. 0 if n is not a prime number.
 */
int is_prime_number(int n)
{
        if (n &amp;lt;= 1)
                return (0);
        return (is_prime(n, 2));
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;is_prime_number
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;make the first check that the number supplied is not 1 or less than 1 as prime numbers only start from 2 upward. Then call&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;is_prime
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to finish the check if the function is a prime number.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;br&gt;
This is my implementation of C program to check prime number, feel free to give your thoughts in the comment section.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Rename a Field in Mongoose with Example</title>
      <dc:creator>Sulaiman Aminu Barkindo</dc:creator>
      <pubDate>Sun, 11 Sep 2022 22:14:42 +0000</pubDate>
      <link>https://dev.to/sulaimanaminubarkindo/how-to-rename-a-field-in-mongoose-with-example-43pn</link>
      <guid>https://dev.to/sulaimanaminubarkindo/how-to-rename-a-field-in-mongoose-with-example-43pn</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Sometimes you may want to change the name of a field in your Schema for different reasons. If you are using mongoose performing only &lt;code&gt;$rename&lt;/code&gt; operation may not work for you. In this article, you will see how to achieve renaming a field in mongoose in three (3) easy steps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's Dive In&lt;/strong&gt;&lt;br&gt;
Assuming we have this user schema &lt;br&gt;
&lt;code&gt;{&lt;br&gt;
  firstName: String,&lt;br&gt;
  surname: String,&lt;br&gt;
  username: String&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
and we have documents in the collection &lt;br&gt;
&lt;code&gt;[&lt;br&gt;
  {&lt;br&gt;
    "_id": ObjectId("5a934e000102030405000000"),&lt;br&gt;
    "firstName": "Sulaiman",&lt;br&gt;
    "surname": "Aminu",&lt;br&gt;
    "username": "souley"&lt;br&gt;
  },&lt;br&gt;
  {&lt;br&gt;
    "_id": ObjectId("5a934e000102030405000001"),&lt;br&gt;
    "firstName": "Alice",&lt;br&gt;
    "surname": "Bob",&lt;br&gt;
    "username": "Aladin"&lt;br&gt;
  }&lt;br&gt;
]&lt;/code&gt;&lt;br&gt;
we want to rename the field &lt;code&gt;surname&lt;/code&gt; to &lt;code&gt;lastName&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Add the New field Name in the Schema&lt;/strong&gt;&lt;br&gt;
To rename a field you need to first add the name you want the field to become in your schema.&lt;br&gt;
&lt;code&gt;{&lt;br&gt;
  firstName: String,&lt;br&gt;
  surname: String, // leave this for now&lt;br&gt;
  lastName: String, // this is the added field&lt;br&gt;
  username: String&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Rename the Field using &lt;code&gt;$rename&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
we can use the following code to rename the field.&lt;br&gt;
&lt;code&gt;db.collection.updateMany({}, { $rename: { "surname": "lastName" } } )&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now the documents will look like this&lt;br&gt;
&lt;code&gt;[&lt;br&gt;
  {&lt;br&gt;
    "LastName": "Aminu",&lt;br&gt;
    "_id": ObjectId("5a934e000102030405000000"),&lt;br&gt;
    "firstName": "Sulaiman",&lt;br&gt;
    "username": "souley"&lt;br&gt;
  },&lt;br&gt;
  {&lt;br&gt;
    "_id": ObjectId("5a934e000102030405000001"),&lt;br&gt;
    "firstName": "Alice",&lt;br&gt;
    "lastName": "Bob",&lt;br&gt;
    "username": "Aladin"&lt;br&gt;
  }&lt;br&gt;
]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Remove the old Field Name if You Want to&lt;/strong&gt;&lt;br&gt;
Now, we can safely delete the old field name from our schema if we don't need it anymore.&lt;br&gt;
&lt;code&gt;{&lt;br&gt;
  firstName: String,&lt;br&gt;
  surname: String, // you can remove this now &lt;br&gt;
  lastName: String, &lt;br&gt;
  username: String&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In Conclusion&lt;/strong&gt;&lt;br&gt;
To rename a field in mongoose you will need to add the new field in the schema, rename the field with &lt;code&gt;$rename&lt;/code&gt; operator, and lastly, delete the field from your schema if you want to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;More Info on &lt;code&gt;$rename&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://www.mongodb.com/docs/manual/reference/operator/update/rename/" rel="noopener noreferrer"&gt;
      mongodb.com
    &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>mongoose</category>
      <category>mongodb</category>
    </item>
  </channel>
</rss>
