Blog, Web Development

Mock Data Alternatives other than DBMS

Most programmer initiate a project and want to test it immediately. Some feel a bit complicated and burdened on building a database design just for testing and working on features. It happens on me, so most people will search for alternatives of data mock. Many options, like using a file or an extension or package.

For some playground projects, I always playing and experimenting with Laravel Frameworks. Sometimes, I felt burdened to create the migration etc. Wonder what the developer guys will do when initiating the front end on the projects when it depends on the backend. It’s quite burdensome, especially for the FrontEnd Developers.

So the solution is using this extension/package:

typicode/json-server

It was easier for me when have some ideas on projects or features. So later building the front and back end features become easy. This Package give us simplify of making REST API. They claim that we can make API with zero coding in less than 30 seconds.

A data store type of JSON. The data json can be modified easily and become an API. The REST API based on the first layer of object json in files.

{
  "posts": [
    {
      "page_id": 1,
      "title": "json-server",
      "author": "typicode"
    }
  ],
  "comments": [
    {
      "page_id": 1,
      "body": "some comment",
      "postId": 1
    }
  ],
  "profile": {
    "name": "typicode"
  },

That is the custom data generate in the package the file name is db.json. So, based on the previous db.json file, here are all the default routes.

GET    /posts
GET    /posts/1
POST   /posts
PUT    /posts/1
PATCH  /posts/1
DELETE /posts/1

The benefit of using this is for the projects which later want to use MongoDB as the Database Management System in the Cloud. For mock data, that later can be move easilty to the MongoDB in simple way just copy paste the JSON document.


Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!