Notebook of ParsePlatform

What is Parse Platform

Official Website

Terms

Class: Typical table in ordinary SQL databases.
Attribute: Data column in the table.
Master Key: a key generated by te server to use inside cloud functions of the server, passes security. Only being used in cloud functions, not front-end.

Practices

Queries

Get lines by specific column

async function getListByName(_nameToGet){
    const query = new Parse.Query('<TableName(Class)>');
    query.equalTo('name', _nameToGet);
    const list = await query.find();
    if (list) {
        return list;
    }
    return "error".
}

OR-ed Queries

Get by only two different specific query definition

async function getOredResults(_args){
    const query1 = new Parse.Query('SomeTableName');
    query1.greaterThan('someAttribute', someValue);

    const query2 = new Parse.Query('AnotherTableName');
    query2.equalTo('someAttributes', someValue);

    const finalQuery = new Parse.Query.or(query1, query2);

    const result = await query.find();
    if (result) {
        return result;
    }
    return "error".
}

AND-ed Queries

Basically queries can be used multiple times to shape them, like:

...
query.greaterThan('strength', 1000);
query.lesserThan('speed', 500);
return await query.find();
...

For more compicative queries,
Get by only either two specific query definition

async function getOredResults(_args){
    const query_age15 = new Parse.Query('User');
    query_age15.equalTo('age', 15);

    const query_age20 = new Parse.Query('User');
    query_age20.equalTo('age', 20);

    const query_hasFriends = new Parse.Query('User');
    query_hasFriends.exists('friends');

    const query_isTeacher = new Parse.Query('User');
    query2.equalTo('profession', 'teacher');

    const finalQuery = new Parse.Query.and(
        Parse.Query.or(query_age15, query_hasFriends),
        Parse.Query.or(query_age20, query_isTeacher)
    );

    const result = await query.find();
    if (result) {
        return result;
    }
    return "error".
}

Heroku

is the common place for parse server for years. To be able to server a parse server and parse dashboard, heroku has its own methods in command line.

How to create an app

Go to heroku dashboard and create an app. .env data can be given in settings of the app.

How to add the app local folder

Reqs:
– Git must be initialized
– Application folder must be ready as nodejs app

then add the remote repo to reach in heroku.

$ heroku git:remote --remote heroku --app APP_NAME

in order to use that app with that remote, e.g.:

$ git push heroku master

How to clone an heroku app

$ heroku git:clone -a=APP_NAME FOLDER_NAME_TO_CLONE_IN

How to deploy the latest changes in the app

$ git push heroku master

That will upload the latest changes to the specified app’s folder inside heroku, and after that, it builds new app from the repo up there and run the built app automatically, which can be watched in terminal duration building and up’ing processes. .

How to get logs continuously

$ heroku logs -a=APP_NAME --tail