/sftnbooking

Primary LanguageJavaScriptMIT LicenseMIT

sftnbooking

description:

using back4app

class level security:

class level sec image

Alt text

API Back4APP

BASICS requests headers:

headers: {
            'X-Parse-Application-Id': appId,
            'X-Parse-REST-API-Key': restApiKey,
            'X-Parse-JavaScript-Key': apiKey,

        }

        .........

        if (userData) {
        options.headers['X-Parse-Session-Token'] = userData.sessionToken;
    }

-> API reference:

example json:

{
  "name": "A string",
  "beds": 1,
  "location": "A string",
  "owner": { "__type": "Pointer", "className": "_User", "objectId": "<THE_REFERENCED_OBJECT_ID>" },
  "openForBooking": true
}

use this:

"owner": { "__type": "Pointer", "className": "_User", "objectId": "<THE_REFERENCED_OBJECT_ID>" },

owner:

Alt text

just to remeber how 'repeat' works:

Alt text

filter DataBase request b4app:

API Reference > Queries >

api ref constraints

  • Constraints

Alt text

  • OR-AND operators

Alt text

  • Relational Queries

Alt text

REST API :

  • Constraints :
--data-urlencode 'where={"title": "My post title", "likes": { "$gt": 100 }}' \
  • OR operator :
--data-urlencode 'where={"$or":[{"likes":{"$gt":1000}}, {"title":"My great post"}], "author": {"__type":"Pointer","className":"_User","objectId":"kzunnPFh5i"}}' \
  • Relational Queries :
--data-urlencode 'where={"post":{"__type":"Pointer","className":"Post","objectId":"<OBJECT_ID>"}}' \

=>

  • filtering only open for booking rooms :
const endpoints = {
    'rooms': (userId) =>
    
    `/classes/Room?where=${encodeURIComponent(`{"$or":[{"openForBooking":true},{"owner":${JSON.stringify(createPointer('_User', userId))}}]}`)}`,

    'roomById': '/classes/Room/'
}

Idea: map of DB relations:

Alt text

reservation class creation:

reservation class creation

type 'Create class & add columns':

Create class & add columns


documentation about **include** like **populate** in mongoose


_

Queries > Relational Queries >

  • You can also do multi level includes using dot notation. If you wanted to include the post for a comment and the post’s author as well you can do:
--data-urlencode 'include=post.author' \

added new column to reservation class:

addHostToREservation

class level permission of Reservation :

Class Level Permission of reservation