In this section, we will learn about parse-server and how to use it.

  • parse-dashboardThe use and configuration of
  • parse-dashboardInterface introduction

What is the parse – dashboard

Parse-dashboard is a graphical interface for using the Parse-Server database developed by the Parse team. Compared with other MongoDB graphical database operation tools such as Robomongo, Parse-dashboard provides website administrators with a configurable tool for manipulating MongoDB data.

The Parse-Dashboard is positioned between the CMS system and the original data management tool of the database. The tool integrates the PARse-Server API and Master user rights. At the same time, Parse-Dashboard processes parse-defined data formats (Pointer, Relation, etc.) so that data sets can be displayed and manipulated more intuitively

Below is the interface of the original Robomongo tool

The interface for parse-Dashboard is shown below

The biggest difference between Parse-Dashboard and Robomongo is the connection body behind the tools. The following diagram shows how the two tools connect

configuration

The parse-Dashboard configuration is relatively simple. An instance must have the following parameters

  • AppName Indicates the application name displayed on the MANAGEMENT console

  • AppId Application ID of the parse-server

  • MasterKey The super administrator key of the parse-server

  • ServerURL Parse-server service address

optional

  • Password of the login user
  1. Command execution

    After installing parse-Dashboard, you can view the usage help by executing –help

    npm install -g parse-dashboard
    
    # Test
    parse-dashboard --help
    Copy the code

    Parse-server must be started before executing parse-Dashboard. You can then start parse-Dashboard by adding parameters or environment variables from the command line

    parse-dashboard --dev --appId MYAPPID --masterKey MYMASTERKEY --serverURL "http://localhost:1337" --appName MYAPP
    
    The default address is http://localhost:4040
    # output
    The dashboard is now available at http://0.0.0.0:4040/
    
    Copy the code
  2. Configuration file Usage

    In addition to adding parameters or environment variables on the command line, parse-Dashboard can also be started by reading configuration files

    The new dashboard. Config. Json

    {
      "apps": [{"serverURL": "http://localhost:1337/parse"."appId": "MYAPPID"."masterKey": "MYMASTERKEY"."appName": "Example"}}]Copy the code

    Then specify the configuration file by adding the –config parameter in the directory of the file

    parse-dashboard --config dashboard.config.json
    Copy the code
  3. Then type localhost:4040 into your browser, and if you see the parse-Dashboard interface, you’re doing the right thing.

If a parse-Dashboard is used on a remote cloud server, a message is displayed indicating that the connection cannot be made because HTTPS is not used when connecting to the parse-Dashboard

To disable HTTPS security verification, add the –allowInsecureHTTP parameter to the parse-Dashboard command. Do not use this option in production environments. This prevents data loss or server breach due to master key leakage.

parse-dashboard --config dashboard.config.json --allowInsecureHTTP
Copy the code

use

Parse-dashboard displays the User and Role databases of parse-Server by default. The database created by the integration of Role and User contains some default fields and configurations. It also serves as the basic function for User management and Role management of the application. For example, username and email in User are used as login User names, while password is hidden by default

Role

The default fields include:

  • ObjectId Parse Primary key of wrapped data. The data type is String

  • CreatedAt Time when the data is created. The data type is Date

  • UpdatedAt Data update time. The data type is Date

  • An ACL is called an Access Control List, which indicates the Access permission of the data. This is one of the great features of Parse-Server. The permissions of each user can be specified for each entry in each table, as we’ll explain later.

  • Name Indicates the name of the role group. The value is unique globally and the data type is String

  • Users Indicates the users in this user group. The data type is Relation. We will introduce the types of Relation and Pointer in detail later

  • Roles Other user groups that belong to this user group. This user group is usually used for permission inheritance

Role adds the concept of user groups on the basis of users. It usually applies to multiple people who have the same access permissions and can implement permission inheritance. Cool, right? The author used users and user groups to monitor the Zabbix resource pool of the company across the country. User permission levels include the permission levels of the provincial and municipal resource pool administrators at all levels of the company to operate and maintain users, which are running well. About the Role permission levels are explained in the following contents with popular examples

User

Users are a table of users within Parse, including hidden fields such as Session Password and globally unique user identification fields such as USERNAME email

The default fields include:

  • objectIdA primary key
  • mailVerified BooleanType, whether to enable the mailbox authentication function
  • ACL ACLType, data access permission
  • updatedAt DateType, update time
  • createdAt DateType, created at
  • authData ObjectType, third party validation data
  • username StringType, globally unique user name
  • password StringType, which hides the displayed password by default
  • email StringType, the user’s email address

The default table structure for users is basically this. If you have a custom field, you can add it on the console or when you create a user. Parse can add a field of the corresponding type based on the format of the data.

The sample

We can create a piece of data with a simple web request and see the results of our creation in the Parse-Dashboard

Create a parse-server configuration Header: x-parse-application-id x-parse-rest-apI-key

  curl -X POST \
  -H "X-Parse-Application-Id: MYAPPID" \
  -H "X-Parse-REST-API-Key: MYRESTAPIKEY" \
  -H "Content-Type: application/json" \
  -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
  http://localhost:1337/parse/classes/Game
Copy the code

The result returned by the network request contains the result of the operation, indicating that our create request was processed successfully.

{"objectId":"ncuoD5hIfw"."createdAt":"The 2021-01-12 T08:36:56. 846 z"}
Copy the code

Then we refresh in the console to see a new table Game and a data column with the type of each field displayed.

See the official API documentation for more information and usage