Giter Club home page Giter Club logo

generator-mongoose's Introduction

generator-mongoose Build Status

![Gitter](https://badges.gitter.im/Join Chat.svg)

NPM

A generator for Yeoman.

Getting Started

What is Yeoman?

Trick question. It's not a thing. It's this guy:

Basically, he wears a top hat, lives in your computer, and waits for you to tell him what kind of application you wish to create.

Not every new computer comes with a Yeoman pre-installed. He lives in the npm package repository. You only have to ask for him once, then he packs up and moves into your hard drive. Make sure you clean up, he likes new and shiny things.

$ npm install -g yo

Generator Mongoose

While running through a leafy mongodb field he picked up mongoose.

To install generator-mongoose from npm, run:

$ npm install -g generator-mongoose

Finally, initiate the generator:

$ yo mongoose

It should output a file structure similiar to:

.bowerrc
.editorconfig
.jshintrc
config/
  - db.js
public/
  css/  
     - style.css
  js/  
     - script.js
models/
    - post.js
routes/
  - index.js
  - post.js
test/
  - test-post.js
views/
  - index.html
bower.json
Gruntfile.js
package.json
Readme.md

Run the app

Development mode

$ grunt 

or

$ grunt server 

Production mode

$ grunt prod 

Sub Generator Schema

Run the sub generator for schemas:

$ yo mongoose:schema "article|title:String,excerpt:String,content:String,published:Boolean,created:Date"

output:

You're creating a schema for article
With the fields: title,excerpt,content,published,created
   create routes/article.js
   create models/article.js
starting request to schematic for test mock data...
   create test/test-article.js

Getting To Know Yeoman

Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced.

If you'd like to get to know Yeoman better and meet some of his friends, Grunt and Bower, check out the complete Getting Started Guide.

License

MIT License

Bitdeli Badge

generator-mongoose's People

Contributors

acveer avatar afj176 avatar arvindr21 avatar bitdeli-chef avatar exocom avatar gitter-badger avatar marcusbuffett avatar nog3 avatar vikz91 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

generator-mongoose's Issues

Errors upon when generating

I'm getting the following error before the questions right after running yo mongoose:

(!) this.readFileAsString() is deprecated. Use require("html-wiring").readFileAsString() instead.

I'm also getting errors after answering the initialization questions:

(!) #mkdir() is deprecated. Use mkdirp module instead. https://www.npmjs.com/package/mkdirp
(!) #mkdir() is deprecated. Use mkdirp module instead. https://www.npmjs.com/package/mkdirp
events.js:85
      throw er; // Unhandled 'error' event
            ^
ReferenceError: /usr/local/lib/node_modules/generator-mongoose/app/templates/Gruntfile.js:45
    43|     open: {
    44|       server: {
 >> 45|         url: 'http://localhost:<%= express.options.port %>'
    46|       }
    47|     }
    48|   });

express is not defined
    at eval (eval at <anonymous> (/usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/node_modules/mem-fs-editor/node_modules/ejs/lib/ejs.js:455:12), <anonymous>:11:28)
    at /usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/node_modules/mem-fs-editor/node_modules/ejs/lib/ejs.js:482:14
    at Object.exports.render (/usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/node_modules/mem-fs-editor/node_modules/ejs/lib/ejs.js:316:13)
    at copy.process (/usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy-tpl.js:18:18)
    at applyProcessingFunc (/usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy.js:12:16)
    at EditionInterface.exports._copySingle (/usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy.js:55:24)
    at EditionInterface.exports.copy (/usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy.js:22:17)
    at EditionInterface.module.exports [as copyTpl] (/usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy-tpl.js:16:8)
    at MongooseGenerator.template (/usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/lib/actions/actions.js:134:11)
    at MongooseGenerator.copy (/usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/lib/actions/actions.js:43:10)

I answered the questions as follows:

? Database Name: contacts-react
? Database Host: localhost
? Database User:
? Database Password:
? Database Port: 27017
? Will you be using heroku? No

Sub Generator Failing Tests in Travis

  1. mongoose generator creates expected files:
    Uncaught TypeError: object is not a function
    at MongooseGenerator. (/home/travis/build/afj176/generator-mongoose/node_modules/yeoman-generator/lib/base.js:383:5)

  2. mongoose generator mongoose schema generator creates expected files:
    Uncaught TypeError: object is not a function
    at SchemaGenerator. (/home/travis/build/afj176/generator-mongoose/node_modules/yeoman-generator/lib/base.js:383:5)

Configurable sub-generator?

Hi there, I was recently looking around for a generator that could create the boilerplate for mongoose schema/models and here we are.

I wanted to be able to use this generator as a sub-generator for a different project and layout. However the structure of the schema sub-gen is fairly different than the one I'm using. What I'm wondering is, would you be open to using the .yo-rc.json config file to configure the schema sub-gen?

app/index.js could save a default config in yo-rc for the schema gen to use when using this generator solely, but would allow others to define a config section in their own yo-rc and use your generator in any yeoman generated project.

I think it'd be really nice to see the yeoman communities 'outsourcing' to more specialized generators when possible, as it would make the ecosystem more modular and focused. If any of this seems out of scope for this project, no worries I completely understand.

However if you are interested let me know and I'd be glad to discuss in more detail.

Thanks,
Cody

Storing nested object?

When creating a new model. Any particular reason why you are creating nested object for the model values?

example this is how the information is sent

{
    "store": {
        "title": "The annals copied down are therefore incorrect from 1045 to 1052, which has two entries.",
        "tagline": "He developed bronchial problems followed by double pneumonia.",
        "description": "Whittle was separate actions aga... Line in 1917.",
        "email": "Pincus presents James as neither naïve nor stupid nor egotistical.",
        "created": "1999-12-22T07:17:24.032Z"
    }
}

Why not have is flat like so:

{
    "title": "The annals copied down are therefore incorrect from 1045 to 1052, which has two entries.",
    "tagline": "He developed bronchial problems followed by double pneumonia.",
    "description": "Whittle was separate actions aga... Line in 1917.",
    "email": "Pincus presents James as neither naïve nor stupid nor egotistical.",
    "created": "1999-12-22T07:17:24.032Z"
}

I ask because I planned to use it with backbone but, requires extra work to specify the model again (granted the service is specific enough) and then nest the body.

Just wondering if this is preference or another reason I my be missing.

/views/index.html Cannot read property 'get' of undefined

After installation, the default root url '/' returns error in index.js.
Seems the routes map is missing. The app does connect to mongoDB fine, this is application issue.
Steps to reproduce:

  1. Make a new directory for the project
  2. 'yo mongoose' (and provide mongoDB connection params)
  3. 'grunt' (or 'grunt server')

The server should be up & running with the below error message.
C:\mongodb\yoMongooseApp2>grunt server
Running "server" task

Running "express:dev" (express) task
Starting background Express server
Tue, 12 Aug 2014 14:15:04 GMT body-parser deprecated bodyParser: use individual json/urlencoded midd
lewares at app.js:62:9
Express server listening on port 3000 in development mode
Tue, 12 Aug 2014 14:15:04 GMT body-parser deprecated undefined extended: provide extended option at
node_modules\body-parser\index.js:75:29

Running "open:server" (open) task
Successfully connected to: mongodb://localhost/myTestDB

Running "watch" task
Waiting...
GET / 500 5.582 ms - 1195
TypeError: Cannot read property 'get' of undefined
at route.index (C:\mongodb\yoMongooseApp2\routes\index.js:9:33)
at Layer.handle [as handle_request](C:PAwsmongodbyoMongooseApp2node_modulesexpresslibro
uterlayer.js:76:5)
at next (C:\PA\ws\mongodb\yoMongooseApp2\node_modules\express\lib\router\route.js:100:13)
at Route.dispatch (C:\PA\ws\mongodb\yoMongooseApp2\node_modules\express\lib\router\route.js:81:3
)
at Layer.handle [as handle_request](C:PAwsmongodbyoMongooseApp2node_modulesexpresslibro
uterlayer.js:76:5)
at C:\PA\ws\mongodb\yoMongooseApp2\node_modules\express\lib\router\index.js:227:24
at Function.proto.process_params (C:\PA\ws\mongodb\yoMongooseApp2\node_modules\express\lib\route
r\index.js:305:12)
at C:\PA\ws\mongodb\yoMongooseApp2\node_modules\express\lib\router\index.js:221:12
at Function.match_layer (C:\PA\ws\mongodb\yoMongooseApp2\node_modules\express\lib\router\index.j
s:288:3)
at next (C:\PA\ws\mongodb\yoMongooseApp2\node_modules\express\lib\router\index.js:182:10)

Version 0.0.5 will not install on a clean windows install due to "latest" on yo dependency

I am unable to install version 0.0.5 on a windows system and a linux system with a clean node install. I get the following error :

npm ERR! peerinvalid Peer [email protected] wants yo@latest

I can however install version 0.0.4 with out issue. I've made sure that I have the latest version of yo installed (1.1.2)

I am going to do a pull request with the version of yo specified in the package.json instead of using "latest"

My recommended fix is

FROM
"latest"
to
">=1.1.1"

TypeError: Cannot read property 'Base' of undefined

Getting this error when running yo mongoose

TypeError: Cannot read property 'Base' of undefined
    at Object.<anonymous> (/usr/local/lib/node_modules/generator-mongoose/app/index.js:20:51)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.get [as mongoose:app] (/usr/local/lib/node_modules/yo/node_modules/yeoman-environment/lib/store.js:38:27)
    at Store.get (/usr/local/lib/node_modules/yo/node_modules/yeoman-environment/lib/store.js:61:39)

Could this be related to following SO thread: https://stackoverflow.com/questions/42846410/yeoman-generator-cannot-read-property-base-of-undefined-with-1-1-version

undefined exception occurring when grunt is run

Recently downloaded this generator and after installing and running npm install & bower install. Running grunt gives me this error. "Windows cannot find 'http://localhost:undefined'. Make sure you typed the name correctly and try again."
I have tried it on several machines with the same consequences.

I have attached a screenshot of this error.

Any help with this would be greatly appreciated.

mongoose-error-on-grunt-command

Cannot call method 'slugify' of undefined

Hi,
When I run the generator, in the step "Will you be using heroku?" I have this error:

? Will you be using heroku? No
(!) #mkdir() is deprecated. Use mkdirp module instead. https://www.npmjs.com/package/mkdirp
(!) #mkdir() is deprecated. Use mkdirp module instead. https://www.npmjs.com/package/mkdirp
(!) #_ is deprecated. Require your own version of Lodash or underscore.string

events.js:72
        throw er; // Unhandled 'error' event
              ^
TypeError: Cannot call method 'slugify' of undefined
    at eval (eval at <anonymous> (/usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/node_modules/lodash/index.js:10693:16), <anonymous>:8:13)
    at underscore (/usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/lib/util/engines.js:23:45)
    at MongooseGenerator.actions.engine (/usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/lib/actions/actions.js:224:32)
    at MongooseGenerator.template (/usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/lib/actions/actions.js:198:19)
    at MongooseGenerator.app (/usr/local/lib/node_modules/generator-mongoose/app/index.js:76:8)
    at /usr/local/lib/node_modules/generator-mongoose/node_modules/yeoman-generator/lib/base.js:421:16
    at processImmediate [as _immediateCallback] (timers.js:345:15)

I think that is related with this issue: yeoman/generator#766

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.