Skip to content

Fully Mocked in-memory Parse Database Implementation

License

Notifications You must be signed in to change notification settings

FintecimalGit/parse-mockdb

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parse MockDB

Master Build Status: Circle CI

Provides a mocked Parse RESTController compatible with version 1.6+ of the JavaScript SDK.

Installation and Usage

npm install parse-mockdb --save-dev

Enhancements: To make specific test-scenarios sometime is required to define custom createAt, updateAt or objectId, so this fork is able to handle it.

Just add to the object the data to save:

    created_at, updated_at, object_id

Dates can be defined as follow:

    { iso: "2018-03-14T17:46:07.014Z" }
    { timestamp: 1521049641200 } 
    { stringDate: "14/03/2018 11:44:27", format: "DD/MM/YYYY HH:mm:ss"} // format is optional, and the default is: DD/MM/YYYY HH:mm:ss
    data = { 
      object_id: 'zzzzz',
      created_at: { timestamp: 1521049641200 },
      field1: "aaa",
      field2: "dddd" 
    };

    const document = (new Parse.Object('collection_name')).set(data);

    document.save().then((object) => {
      console.log(object) // {"field1":"aaa","field2":"dddd","createdAt":"2018-03-14T17:47:21.200Z","updatedAt":"2018-03-14T17:53:15.985Z","objectId":"zzzzz"}  
    });
'use strict';
const Parse = require('parse-shim');
const ParseMockDB = require('parse-mockdb');

ParseMockDB.mockDB(); // Mock the Parse RESTController

// Perform saves, queries, updates, deletes, etc... using the Parse JS SDK

ParseMockDB.cleanUp(); // Clear the Database
ParseMockDB.unMockDB(); // Un-mock the Parse RESTController

Completeness

  • Basic CRUD (save, destroy, fetch)
  • Query operators ($exists, $in, $nin, $eq, $ne, $lt, $lte, $gt, $gte, $regex, $select, $inQuery, $all, $nearSphere)
  • Update operators (Increment, Add, AddUnique, Remove, Delete)
  • Parse.Relation (AddRelation, RemoveRelation)
  • Parse query dotted notation matching eg { "name.first": "Tyler" })
  • Parse class level permissions
  • Parse.ACL (row level permissions)
  • Parse special classes (Parse.User, Parse.Role, ...)
  • Parse lifecycle hooks (beforeSave - done, afterSave - done, beforeDelete - done, afterDelete)

Tests

npm test

About

Fully Mocked in-memory Parse Database Implementation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%