Coder Social home page Coder Social logo

lab-mongo-crunchbase-1's Introduction

Ironhack Logo

DE | Crunchbase Database

Introduction

You will build an small application to perform queries to crunchbase database.

Crunchbase is the premier destination for discovering industry trends, investments, and news about hundreds of thousands of companies globally. From startups to Fortune 500s, Crunchbase is recognized as the primary source of company intelligence by millions of users globally.

Import data into a database

Inside the starter-code folder you will find the crunchdatabase file.

Use mongoimport command to create a database named crunchbase, and import all the data contained on the file into a collection named companies.

💡 Check mongoimport documentation if you don't remember how to do it. 💡

Let's start

Create a new folder for you project.

$ npm init

Now that we have created the project, add the following packagesclear and mongodb

$ npm install --save mongodb@2     // don´t forget the @2 after mongodb, this will force npm to install that specific version
$ npm install --save clear

Run the main.js file to using the node main.js command in order to connect to the chrunchbase database and companies collection. Then, check how the console asks you to create 17 queries in order to archieve some kind of data filtering:

0.- Exit
1.- List by name all companies.
2.- How many companies are there?
3.- How many companies were founded in 2004?
4.- List by name all companies founded in february of 2004.
5.- List by name all companies founded in the summer of 2004 (april to june) sorted by date.
6.- What companies have offices in "Barcelona".
7.- List the 10 companies with more employees sorted ascending (show name and employees).
8.- Find the company with the name "Facebook"
9.- How many employees has Facebook?
10.- List the name of all the products of Facebook
11.- List the people that are working at Facebook right now (check relationships field)
12.- List all the companies where "david-ebersman" has worked.
13.- List by name the competitors of Facebook
14.- Names of the companies that has "social-networking" in tag-list (be aware that the value of field is a string check regex operators)
15.- How many companies that has "social-network" in tag-list and founded between 2002 and 2016 inclusive
16.- Names and locations of companies that have offices in London
17.- How many companies that has "social-network" in tag-list and founded between 2002 and 2016 inclusive and has offices in New York

As the file already contains the first 3 queries solved for you, you can check how pressing keys 1 to 3 shows requested results.

This is the structure you will find for every case, where you will need to modify the .find() method arguments in every additional case:

case "2":
db.collection('companies').find({}, { name: 1, _id: 0 }).count((error, result) => {
  if (error) {
    console.log(error);
    rl.question(`\nType enter to continue: `, (answer) => { mainMenu() });
  } else {
    console.log(result);
    rl.question(`\nType enter to continue: `, (answer) => { mainMenu() });
  }
})
break;

Now it's your turn

Check the main.js file and replicate the structure above so you can perfom the 17 queries, following the instructions how we did before.

Summary

In this exercise you practice with MongoDB Driver to perform different queries.

Extra Resources

MongoDB NodeJS Driver Documentatio

MongoShell Documentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.