Search code examples
mongodbmongoosemeanjsyo

Read/Write operations in MEAN.js


I have just started with mean.js and am confused about its work flow. I created a new module using yo man generator. I need to be clarified about

  • How a record is been added to the database ie where are the queries.
  • How can a record be updated

Solution

  • All CRUD functions are located inside public/modules/yourModule/controllers you can see yourModule.client.controller.js.

    Inside you can see the functions $scope.create, $scope.remove, $scope.update, $scope.find, $scope.findOne.

    These functions are called in your view public/modules/yourModule/views.

    Inside you can see four files for your CRUD operations create-yourModule.client.view.html, edit-yourModule.client.view.html, list-yourModule.client.view.html, view-yourModule.client.view.html.

    For eg: in create-yourModule.client.view.html on form you can see <form class="form-horizontal" data-ng-submit="create()"> the create() function is called.

    If you want to see the mongoose model schema app/models/yourModule.server.model.js

    For more details watch this good tutorial here, (watch video 9 to 15)