S
S
Sanders Rocket2020-05-08 21:46:30
SQLite
Sanders Rocket, 2020-05-08 21:46:30

How to do an access check on a database?

We have such a database:
DFGv30j.png
What do you need from it? A check should be made to see if the person with the VKid (who is making the request) has dostuplvl higher or lower than 5 or whatever.
How to do it?
My guesses:

function checkdostup(){
  let sql = 'select dostuplvl from dostups';
  db.all(sql, [], (err, rows) => {
    if (err) {
      throw err;
    }
    rows.forEach((row) => {
      console.log(row)
      return row.dostuplvl;
    });
  }); 
}

So that you can then make a check with a regular request, an example:
if (checkdostup > 5) {
 
}

The ID of the person making the request is msg.message.from_id

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2020-05-08
@notiv-nt

select dostuplvl from dostups where vkid = ${from_id}

dostup facepalm.jpg, well, okay
, select all the records that match the person's id, and check for each if there are a lot of them (?) or if one returns, then here with the usual if

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question