Skip to main content

Posts

Say for in a database maintenance activity we drop a collection by mistake, we can restore to the last state just before dropping the database using oplog file and the latest available backup.Follow the below steps to restore the database to last state: 1. use local db.oplog.rs.findOne({"o.drop":" "}) we will get epoch_sec for that particular drop statement. 2. Dump the oplog file mongodump -d local -c oplog.rs -out /data/oplog_dump -query {"ns":{"nin":[config.system.sessions,config.cache.collections]}} 3. Restore the latest backup using mongorestore 4. Restore the oplog upto the epoch time of collection drop mongorestore --oplogReplay --oplogFile --oplogLimit epoch_sec  
In the last blog , the dashboard.component.html has been styled by using angular material by using mat card and other similar tags.Follow the below steps to implement angular material: 1. Go to project path and in cmd and type below command: ng add @angular/material 2.  Open the src/app/app.module.ts file and add the below code for material: import  {  BrowserModule  }  from   '@angular/platform-browser' ; import  {  NgModule  }  from   '@angular/core' ; import  {  AppRoutingModule  }  from   './app-routing.module' ; import  {  AppComponent  }  from   './app.component' ; import  {  DashboardComponent  }  from   './dashboard/dashboard.component' ; import  {  AboutComponent  }  from   './about/about.component' ; import  {  HttpClientModule  }  from   '@angular/common/http' ; import  {  BrowserAnimationsModule  }  from   '@angular/platform-browser/animations' ; import  {  MatButtonModule  }  from   &#
To call a rest api service in angular, follow the below steps after setting up a fake service and routings as mentioned in previous blogs: 1. Generate an Angular service that interfaces with the JSON REST API.  ng generate service data 2. Write    src/app/data.service.ts  file to call the fake rest api in the getAllBooks method as below: import  {  Injectable  }  from   '@angular/core' ; import  {  HttpClient ,  HttpErrorResponse  }  from   '@angular/common/http' ; import  {   throwError  }  from   'rxjs' ; import  {  retry ,  catchError  }  from   'rxjs/operators' ; @ Injectable ({    providedIn:   'root' }) export   class   DataService  {    private   REST_API_SERVER  =  "http://localhost:3000" ;    constructor ( private   httpClient :  HttpClient ) { }    handleError ( error :  HttpErrorResponse ) {      let   errorMessage  =  'Unknown error!' ;      if  ( error . error   instanceof   Er
To call a fake rest api service from our angular application , we can use a fake service using angular.Follow the below steps to create a fake server hosting a json database for angular service calls: 1. In the project path run the below command from cmd: npm install json-server --save 2. Inside project folder create a folder "server" with a json file, database.json with below data {     "books": [ {id: 1, title: "Lockdown Dairies", author: "raje"}, {id: 2, title: "who do", author: "qao"} ] } 3. Add the below lines in "scripts" tag of package.json of your project "server": "json-server --watch ./server/database.json" 4. Run the below command to run the fake service npm run server The resource would be available at : http://localhost:3000/books
We can route hyperlinks to route to any of the components based on url changes using single page application at client side instead of loading whole page.So basically what routing does is: * Page navigation, to create " Single Page Application" * Route maps a URL to its component Steps for routing: 1. Importing @angular/router package in package.json ( already present when ng new is created ) 2. Define base url in index.html    < base   href = "/" > 3. Create hyperlink for route ( in app.component.html) eg: < a   class = "nav-link"   routerLink = "dashboard" > Dashboard </ a > 4. Create router module in app-routing.module.ts ( add path and component for components to be added like dashboard, rest will already be created by ng new initially) import  {  NgModule  }  from   '@angular/core' ; import  {  Routes ,  RouterModule  }  from   '@angular/router' ; import  {  DashboardComp
To implement bootstrap in an angular application after creating it with ng new command , follow the below steps: 1. Open command prompt and cd to the project directory and run  below commands npm install jquery –save npm install popper.js – save npm install bootstrap –save npm install font-awesome –save 2.  Open project folder in visual studio and in the angular.json file of the project add the below styles and scripts:     "styles": [               "src/styles.scss",               "node_modules/bootstrap/dist/css/bootstrap.css",               "node_modules/font-awesome/css/font-awesome.css"             ],             "scripts": [               "node_modules/jquery/dist/jquery.js",               "node_modules/popper.js/dist/umd/popper.js",               "node_modules/bootstrap/dist/js/bootstrap.js"             ] 3. To add a nav bar with dashboard and about as two
Angular JS components are a below:         The benefits of Angular JS  are: The building blocks of Angular are: