GithubHelp home page GithubHelp logo

irondictionary's Introduction

Irondictionary

## To set up the project with Git

First, create a repository on GitHub and clone the repository.

$ git clone https://github.com/mc100s/my-project-cloned.git
$ cd my-project-cloned
$ irongenerate --auth .
$ git add .
$ git commit -m "First commit"
$ git push origin master

Iterations

Iteration 1 | Create the Models and Seeds

### Solution 1

// /models/Entry.js
const mongoose = require('mongoose');
const Schema   = mongoose.Schema;

const entrySchema = new Schema({
  originalWord: { 
    type: String, 
    required: true,
    trim: true,
    minlength: 1
  },
  convertedWord: { 
    type: String, 
    required: true,
    trim: true,
    minlength: 1
  },
});

const Entry = mongoose.model('Entry', entrySchema);
module.exports = Entry;
// /bin/seeds.js
const mongoose = require('mongoose');
const Entry = require('../models/Entry');

mongoose
.connect('mongodb://localhost/irondictionary', {useNewUrlParser: true})
.then(x => {
  console.log(`Connected to Mongo! Database name: "${x.connections[0].name}"`)
})
.catch(err => {
  console.error('Error connecting to mongo', err)
});

let entriesToCreate = [
  {
    originalWord: "hello",
    convertedWord: "salut",
  },
  {
    originalWord: "today",
    convertedWord: "aujourd'hui",
  },
  {
    originalWord: "bye",
    convertedWord: "salut",
  },
  {
    originalWord: "world",
    convertedWord: "monde",
  }
]

Entry.deleteMany()
.then(() => Entry.create(entriesToCreate))
.then(entries => {
  console.log(entries.length + ' entries created')
  mongoose.disconnect()
})

irondictionary's People

Contributors

mc100s avatar

Watchers

James Cloos avatar

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.