ReplAPI-it / ReplAPI.it-NodeJS

[DEPRECIATED] 𝙀𝙫𝙚𝙧𝙮𝙩𝙝𝙞𝙣𝙜 𝙍𝙚𝙥𝙡𝙞𝙩, 𝙖𝙡𝙡 𝙖𝙩 𝙮𝙤𝙪𝙧 𝙙𝙞𝙨𝙥𝙤𝙨𝙖𝙡. This is the single most extensive Replit package, allowing you to access various parts of the site with just a few classes and methods. Maintained by @RayhanADev.
GNU General Public License v3.0
34 stars 1 forks source link

ReplDB interfacing options for ReplAPI.it #25

Open rayhanadev opened 3 years ago

rayhanadev commented 3 years ago

One idea no Replit API package has managed so far (to my knowledge), is an interfacing option with ReplDB. I don't quite mean enveloping the ReplDB package with ReplAPI.it, but rather sending requests to the endpoint.

Ideas:

This doesn't do much with just the basic functions and it could possibly be easier for users if there are utilities...

rayhanadev commented 3 years ago

Pushed an update (2.0.8 on 4/25/2021) with the Database as an Experimental Feature. To use it, turn on Experimental Features.

The Database class will support ReplDB functions or the new ReplDB+ setup for ReplDB (in development by me).

What is ReplDB+? Unlike the original ReplDB, ReplDB+ is an opinionated, easy-to-use database built on top of the existing ReplDB setup. It will hopefully include many features that give ReplDB a feel similar to a modern database. Modeled after Cloud Firestore, ReplDB+ is a NoSQL database with collections that contain documents of data. It will have more expressive functions, ease-of-life methods, privacy features, and more!

Current usage:

Of course, none of these do anything right now.

Current Database Functions

More to come!

rayhanadev commented 3 years ago

Some (hopefully) planned features: Deletion

Security

Ease of life Functions

rayhanadev commented 3 years ago

Here are the database options, except easier on the eyes: When you initialize a Database (using constructor)

{
  password: '', // <String> (required) A password to use to access the database
  type: '', // <String> (required) The type of database; options include "repldb" or "plus"
  collaborators: {}, // <Object> (optional) The collaborators on a database (see below)
  encrypted: [], // <Array> (optional) Whether to use encryption automatically (see below)
  'max-items': 0, // <Integer> (optional)
}

In the background, these are the options that are coded into the database:

{
  id: String(dbToken).split('/')[4] || process.env.REPLIT_DB_URL.split('/')[4],
  owner: process.env.REPL_OWNER,
  collaborators: { ...options.collaborators } || {},
  password: {
    hashedpassword: '',
    salt: ''
  },
  type: '',
  encrypted: options.encrypted || [false],
  'max-items': options['max-items'] || 10,
}

What do you put in the collaborator field?

collaborators: {
  'name-of-collaborator': {
    'access': 'read'
  }
}

or:

collaborators: {
  'name-of-collaborator': {
    'access': ['read', 'write']
  }
}

What do you put in the encrypted field?

encrypted: [true, 'name-of-encryption']

or:

encrypted: [false]
rayhanadev commented 3 years ago

Added deletion features :)

Deletion

  • Database.deleteCollection(collectionName)
  • Database.deleteDoc(collectionName, docName)
  • Database.deleteField(collectionName, docName, path-to-field)