<?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: Balaji Muthukumar</title>
    <description>The latest articles on DEV Community by Balaji Muthukumar (@balaajimuthukumar).</description>
    <link>https://dev.to/balaajimuthukumar</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%2F359564%2F76aae01f-1b25-4c35-bd39-2329e3eaca6f.jpg</url>
      <title>DEV Community: Balaji Muthukumar</title>
      <link>https://dev.to/balaajimuthukumar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/balaajimuthukumar"/>
    <language>en</language>
    <item>
      <title>Firebase, coding with Javascript - examples. part-1 </title>
      <dc:creator>Balaji Muthukumar</dc:creator>
      <pubDate>Fri, 11 Dec 2020 14:12:16 +0000</pubDate>
      <link>https://dev.to/balaajimuthukumar/firebase-coding-with-javascript-examples-part-1-14e6</link>
      <guid>https://dev.to/balaajimuthukumar/firebase-coding-with-javascript-examples-part-1-14e6</guid>
      <description>&lt;p&gt;&lt;strong&gt;Collection Reference&lt;/strong&gt;&lt;br&gt;
The collection reference is used to read or write documents or query for the documents that are available in the cloud firestore or db(These document in the cloud can be accessed using for..of method&lt;/p&gt;

&lt;pre&gt;
'''javascript
const fs = require('firebase-admin');
var db = fs.firestore();
const collRef = db.collection('fieldname').doc('fieldname');
let arrayVal = new Array();

// async function to get the data

async function myFunction(){
 let docSnapshot = await collRef.get(); 
 for(let val of Object.key(docSnapshot.data())) 
  {
       arrayVal.push([docSnapshot.data()[val],val]);
   }
}
console.log(arrayVal);
'''
&lt;/pre&gt;

&lt;p&gt;The output will be:&lt;/p&gt;

&lt;pre&gt;
[["value1","key1"],["value2","key2"]]
&lt;/pre&gt;

&lt;p&gt;or the object can be enumerated by applying a foreach method). &lt;/p&gt;

&lt;pre&gt;
'''javascript
const fs = require('firebase-admin');
var db = fs.firestore();
const collRef = db.collection('fieldname').doc('fieldname');
let arrayVal = new Array();

// async function to get the data

async function myFunc(){
   let docSnapshot = await collRef.get(); 
Object.keys(docSnapshot.data()).foreach((item) =&amp;gt; 
 {
   arrayVal.push([docSnapshot.data()[item],item]);
 }
}

console.log(arrayVal);
'''
&lt;/pre&gt;

&lt;p&gt;The output will be:&lt;/p&gt;

&lt;pre&gt;
[["value1","key1"],["value2","key2"]]
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;.get()&lt;/strong&gt;&lt;br&gt;
The get method is used to query the db for the documents that the firebase is having. This method is implemented in such a way that you can only retrieve existing data. So the query will request the cloud for the data and the response will be a promise that has a Query snapshot(Read the below two definition and read this method again!). You only get query snapshot if and only if you request entire collection, else it becomes a query document snapshot.&lt;/p&gt;

&lt;pre&gt;
'''javascript
const collRef = db.collection('fieldname')

//this is called inside async function as 
//docsnapshot in previous example

let querySnapshot = await collRef.get(); 

'''
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Document Snapshot&lt;/strong&gt;&lt;br&gt;
This will return the field from documents selectively, because the user will be manually typing the path for the document.  This document snapshot, figuratively speaking will have a collection of data fields which are called document data.&lt;/p&gt;

&lt;p&gt;The document snapshot and Query Document snapshot are similar but the only difference is it will contain additional query parameters as part of a query. &lt;/p&gt;

&lt;p&gt;Both the query document snapshot and document snapshot return values can be retrieved using .data() or .get('field').&lt;/p&gt;

&lt;p&gt;Response values wil be:&lt;/p&gt;

&lt;pre&gt;
QueryDocumentSnapshot {
  _fieldsProto: {
    email: { stringValue: 'mbalaaji1995@gmail.com', valueType: 'stringValue' }
  },
  _ref: DocumentReference {
    _firestore: Firestore {
      _settings: [Object],
      _settingsFrozen: true,
      _serializer: [Serializer],
      _projectId: 'quizapp-011220',
      registeredListenersCount: 0,
      bulkWritersCount: 0,
      _backoffSettings: [Object],
      _clientPool: [ClientPool]
    },
    _path: ResourcePath { segments: [Array] },
    _converter: {
      toFirestore: [Function: toFirestore],
      fromFirestore: [Function: fromFirestore]
    }
  },
  _serializer: Serializer {
    createReference: [Function (anonymous)],
    createInteger: [Function (anonymous)],
    allowUndefined: false
  },
  _readTime: Timestamp { _seconds: 1607694363, _nanoseconds: 641576000 },     
  _createTime: Timestamp { _seconds: 1606843021, _nanoseconds: 548845000 },   
  _updateTime: Timestamp { _seconds: 1607497484, _nanoseconds: 962141000 }    
}
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Query Snapshot&lt;/strong&gt;&lt;br&gt;
Query snapshot is something you will get when requested all the documents in a collection. &lt;/p&gt;

&lt;p&gt;Response values wil be:&lt;/p&gt;

&lt;pre&gt;
QuerySnapshot {
  _query: CollectionReference {
    _firestore: Firestore {
      _settings: [Object],
      _settingsFrozen: true,
      _serializer: [Serializer],
      _projectId: 'quizapp-011220',
      registeredListenersCount: 0,
      bulkWritersCount: 0,
      _backoffSettings: [Object],
      _clientPool: [ClientPool]
    },
    _queryOptions: QueryOptions {
      parentPath: [ResourcePath],
      collectionId: 'FreshPrinceChoice',
      converter: [Object],
      allDescendants: false,
      fieldFilters: [],
      fieldOrders: [],
      startAt: undefined,
      endAt: undefined,
      limit: undefined,
      limitType: undefined,
      offset: undefined,
      projection: undefined
    },
    _serializer: Serializer {
      createReference: [Function (anonymous)],
      createInteger: [Function (anonymous)],
      allowUndefined: false
    },
    _allowUndefined: false
  },
  _readTime: Timestamp { _seconds: 1607695217, _nanoseconds: 742184000 },
  _size: 4,
  _materializedDocs: null,
  _materializedChanges: null,
  _docs: [Function (anonymous)],
  _changes: [Function (anonymous)]
}
&lt;/pre&gt;

</description>
      <category>javascript</category>
      <category>nosql</category>
      <category>firebase</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Module, Packages, Dependencies! What are they?</title>
      <dc:creator>Balaji Muthukumar</dc:creator>
      <pubDate>Thu, 26 Nov 2020 18:03:16 +0000</pubDate>
      <link>https://dev.to/balaajimuthukumar/module-packages-dependencies-what-are-they-2hg5</link>
      <guid>https://dev.to/balaajimuthukumar/module-packages-dependencies-what-are-they-2hg5</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dZ73uZQV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q6uljrwhw1z063dbme5h.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dZ73uZQV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q6uljrwhw1z063dbme5h.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Module is single file of code. Package is a group of modules in a directory. Dependencies are added files in a package to assist the module files to download other modules to have additional features without having to rewrite the code from scratch and use someone else's code.&lt;/p&gt;

&lt;p&gt;This will be useful when you work in an organization and you are responsible for a module in a big project. The big projects are maintained by hundreds and thousands of developers(eg Linux os or Microsoft office..etc) where the project will have new features or bug fixes in weekly or monthly basis. These cannot be re-written from scratch. Let's say the big projects have lots of modules with duplicate copies across your system, How do you face this? Understand the entire project?. No, This is where having packages could save you. The packages are files arranged in a central repository in cloud or installed globally in your local pc so that you could import it in you module and use it. Now importing the external modules to your module, How do you do that? Simply by adding an "Import module_name"? Maybe. But in Javascript it does not work like that. The dependency files are created and the names of the files to be added are added in it. This will be read by the IDE to search and download the packages.&lt;/p&gt;

&lt;p&gt;Unlike other programming languages, Javascript will need you to add packages individually for each project. This will be useful when you need to fix a bug in the package or do minor alterations in the packages will not affect the files globally and wont affect other people's work.&lt;/p&gt;

&lt;p&gt;There are few things I thought should share for the noobs. &lt;/p&gt;

&lt;p&gt;+Please don't try to add separate Javascript file for html if you are not using any framework. It wont work. There are factors like changing the script type to module or developing a Javascript listener and rendering the html file as well importing different modules need to done. &lt;/p&gt;

&lt;p&gt;+Don't worry about the lines of code being too much or efficient. first try to produce output. Stressing too much will make you procrastinate.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
