This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task CreateIndexOnCollection(IMongoCollection<BsonDocument> collection, string field) | |
{ | |
var keys = Builders<BsonDocument>.IndexKeys.Ascending(field); | |
await collection.Indexes.CreateOneAsync(keys); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task CreateIndexOnNameField() | |
{ | |
var keys = Builders<User>.IndexKeys.Ascending(x => x.Name); | |
await _usersCollection.Indexes.CreateOneAsync(keys); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "nodetest", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "command" | |
}, | |
"dependencies": { | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class User { | |
constructor( | |
public _id: string, | |
public name : String, | |
public age: Number, | |
public location : string, | |
public blog: string | |
){} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
// Define a schema. | |
var userSchema = new Schema({ | |
name: String, | |
blog: String, | |
age: Number, | |
location: String | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { FormsModule } from '@angular/forms'; | |
import { AppComponent } from './app.component'; | |
import { HttpModule } from '@angular/http'; | |
import { UserComponent } from './users/users.component'; | |
import { UserService } from './services/users.service'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
@Component({ | |
selector: 'example', | |
templateUrl: './example.component.html', | |
}) | |
export class ExampleComponent implements OnInit { | |
constructor() { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="form-group col-sm-2"> | |
<label for="insertUser">Insert User:</label> | |
<input class="form-control" type="text" placeholder="Name" [(ngModel)]="this.newUser.name" [ngModelOptions]="{standalone: true}"/> | |
<input class="form-control" type="text" placeholder="Blog" [(ngModel)]="this.newUser.blog" [ngModelOptions]="{standalone: true}"/> | |
<input class="form-control" type="text" placeholder="Age" [(ngModel)]="this.newUser.age" [ngModelOptions]="{standalone: true}"/> | |
<input class="form-control" type="text" placeholder="Location" [(ngModel)]="this.newUser.location" [ngModelOptions]="{standalone: true}"/> | |
<button class="btn btn-default" (click)="insertNewUser()"> Insert User </button> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'users', | |
templateUrl: './users.component.html', | |
}) | |
export class UserComponent implements OnInit { | |
newUser: User; | |
constructor( | |
private userService: UserService |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { Http, URLSearchParams } from '@angular/http'; | |
import { Observable } from 'rxjs/Observable'; | |
import { Subject } from 'rxjs/Subject'; | |
import { User } from '../model/user'; | |
import 'rxjs/add/operator/map'; | |
import 'rxjs/add/operator/catch'; | |
@Injectable() | |
export class UserService { |