Details zum E-Book

Mongoose for Application Development. Mongoose streamlines application development on the Node.js stack and this book is the ideal guide to both the concepts and practical application. From connecting to a database to re-usable plugins, it's all here

Mongoose for Application Development. Mongoose streamlines application development on the Node.js stack and this book is the ideal guide to both the concepts and practical application. From connecting to a database to re-usable plugins, it's all here

Simon Holmes

E-book
Mongoose is all about putting the data model where it should be: in your application. You can control everything from within your application in JavaScript, eliminating the need to work with the database or a separate management system.

Mongoose for Application Development is a practical, hands-on guide that takes you from installing the technology stack through the steps of developing a web application. It covers the key features of Mongoose and how to use them to rapidly develop a Node.js and MongoDB application.

This book introduces the full technology stack of Node.js, MongoDB, Express, and Mongoose. It will take you through the process of building an application on this stack with a focus on how Mongoose makes the process quicker and easier.

You will see how Mongoose removes a layer of complexity when dealing with MongoDB whilst giving you more control over your data from your application. You will learn how to define schemas and models for your data in JavaScript. Using these schemas and models, you will learn how to build the cornerstone of any web application that will include CRUD operations (creating, reading, updating, and deleting data). If you want to learn how to build applications quickly and efficiently using Node.js, then Mongoose and this book are ideal for you.

Using practical examples throughout, Mongoose for Application Development not only teaches you about the concepts of Mongoose, but walks through how to use them to build a real-life application.
  • Mongoose for Application Development
    • Table of Contents
    • Mongoose for Application Development
    • Credits
    • About the Author
    • About the Reviewers
    • www.PacktPub.com
      • Support files, eBooks, discount offers and more
        • Why Subscribe?
        • Free Access for Packt account holders
    • Preface
      • What this book covers
      • What you need for this book
      • Who this book is for
      • Conventions
      • Reader feedback
      • Customer support
        • Downloading the example code
        • Errata
        • Piracy
        • Questions
    • 1. Introducing Mongoose to the Technology Stack
      • The technology stack Node.js, npm, MongoDB, and Express
        • The language and the server JavaScript and Node
        • Single-threaded versus multithreaded
          • Blocking versus non-blocking code
            • JavaScript callbacks
            • Running the callback
            • A Node.js example
        • The database MongoDB
        • The framework Express
      • What Mongoose is all about
        • What is Mongoose good for?
        • What Mongoose is not ideally suited for
        • The cornerstones of Mongoose
          • Mongoose schemas
          • Mongoose models
      • Installing the full stack
        • Installing the prerequisites
        • Installing Node.js
        • Installing npm
        • Installing MongoDB
        • Installing Express.js
        • Installing Mongoose
          • Direct installation into project
          • Using project dependencies package.json
        • Creating a project
      • Summary
    • 2. Establishing a Database Connection
      • Mongoose default connection
        • Using multiple connections
      • About the connection string
        • Setting the port
        • Specifying a database user
      • Connection options
      • Closing the connection
        • Calling the close command
        • Closing when the Node process ends
      • Connection events
      • Connecting our project
        • Creating the connection
        • Catching the events
        • Opening the connection at application start
        • Creating the database
      • Summary
    • 3. Schemas and Models
      • Introducing schemas
        • Field sizes
      • Data types allowed in schemas
        • String
        • Number
        • Date
        • Boolean
        • Buffer
        • ObjectId
        • Mixed
          • Tracking changes to Mixed type
        • Array
          • Warning array defined as mixed type
        • Custom SchemaTypes
      • Where to write the schemas
      • Writing a schema
        • Modifying an existing schema
        • Setting a default value
        • Only allowing unique entries
        • Our final User schema
        • Whats that "__v" thing?
          • Why is this needed?
        • Defining the Project schema
          • Improving the Project schema
      • Building models
        • Instances
          • Interacting with instances
          • Finding a single instance
          • Finding many instances
        • Considerations when choosing your model name
      • Setting the collection name
        • Overriding the collection name in the schema
        • Overriding the collection name in the model
        • Building models from our schemas
      • Our complete code
      • Summary
    • 4. Interacting with Data an Introduction
      • Model methods and instance methods
      • Setting up the project
        • Code structure
          • Adding the routes files
          • Tying the routes to Mongoose models
        • URLs and routes
          • Routes for user management
          • Routes for project management
      • Summary
    • 5. Interacting with Data Creation
      • Creating an instance
        • Adding data to the instance
      • Saving an instance
        • Using the saved data
      • Creating and saving database entry in one step
        • Chaining methods
        • The Model.create() method
      • CRUD create data
        • Adding a new user form
          • Adding the Jade template
          • Linking the view to the URL
        • Adding the create user function
          • Error trapping
          • Creating a user session
        • Displaying the confirmation page
        • Try it out!
        • Adding create project functionality
          • Routes
          • New files and functions
      • Summary
    • 6. Interacting with Data Reading, Querying, and Finding
      • Approaches to find and read data
        • Using the QueryBuilder
        • Single query operation
        • Static helper methods finding data
      • CRUD reading user and project data
        • findOne() finding a single user
          • Login form
          • Login action
          • Housekeeping adding homepage links
          • Try it out!
        • find() finding a list of projects and returning JSON to AJAX
          • Creating a new static find method
          • Setting up the route
          • Updating the view
          • Building the AJAX call
          • Try it out!
        • findByld() finding a single project
          • Route setup
          • Creating the view
      • Summary
    • 7. Interacting with Data Updating
      • Model helper methods
        • Building the commands
        • Which method to choose
        • The catch
      • The three-step find-edit-save approach
      • CRUD editing users and projects
        • Tracking user login
        • Editing the current user
          • Routes in use
          • Setting up the form
          • Setting up the controllers
          • Committing the edit
        • Editing projects
          • Routes
          • New files and functions
      • Summary
    • 8. Interacting with Data Deleting
      • Deleting data
      • CRUD deleting user and projects
        • The "Are you sure" page
        • Deleting the user
          • Improving on this
        • Deleting individual projects
          • Routes
          • New files and functions
      • Summary
    • 9. Validating Data
      • Mongoose validation the basics
        • Default validators
          • All SchemaTypes
          • Number SchemaType
          • String SchemaType
      • Understanding validation errors
      • Doing it your way create custom validation
        • Single function no custom error message
        • Returning a custom error message
          • Validating a regular expression
          • Taking the messages out of the schema
        • Using multiple re-usable validators
        • Non-blocking, asynchronous validation
        • Extending Mongoose validation
      • Adding validation to our project
      • Summary
    • 10. Complex Schemas
      • Population references to other collections
        • Defining data for population
        • Saving population references
        • Retrieving populated data
          • Querying to return a subset of results
          • Populating into multiple parent items
      • Subdocuments
        • Creating subdocuments
          • Saving and validation
        • Retrieving subdocuments
          • Accessing a specific subdocument
        • Deleting subdocuments
      • Data management when modifying existing schemas
      • Summary
    • 11. Plugins Re-using Code
      • Reusable schema plugins
        • Creating a schema plugin
          • Applying the plugin to an existing schema
          • Using an external file
          • Using schema middleware
            • Not just for plugins
      • Sharing with the community
      • Summary
    • Index
  • Titel: Mongoose for Application Development. Mongoose streamlines application development on the Node.js stack and this book is the ideal guide to both the concepts and practical application. From connecting to a database to re-usable plugins, it's all here
  • Autor: Simon Holmes
  • Originaler Titel: Mongoose for Application Development. Mongoose streamlines application development on the Node.js stack and this book is the ideal guide to both the concepts and practical application. From connecting to a database to re-usable plugins, it's all here.
  • ISBN: 9781782168201, 9781782168201
  • Veröffentlichungsdatum: 2013-08-26
  • Format: E-book
  • Artikelkennung: e_3bhq
  • Verleger: Packt Publishing