0.5.2 • Published 5 years ago

razor-layer v0.5.2

Weekly downloads
3
License
MIT
Repository
-
Last release
5 years ago

RazorLayer

configuration

const RazorLayer = require("razor-layer");
const db = new RazorLayer({
   config: {
       host: "localhost",
       user: "root",
       password: "",
       database: "_lang_proto"
   }
});

examples

app.get("/", async (request, resource) => {
    const results = await db.table("match_result")
                // when you omit third parameter, the default operator is "="
                .where("score", 50, ">=")
                .andWhere("is_public", true)
                .orderBy("score", "DESC")
                .limit(3)
                .offset(1)
                .findAll();
    
    // you can also try orWhere() and orderByRand()

    // find a record by id
    const match = await db.table("match_result").find(23);

    const newMatch = { score: 999, is_public: true };
    const { insertId } = await db.table("match_result").insert(newMatch);
    
    // updating match info (when updating row you have to include row id)
    newMatch.id = insertId; // e.g. { id: 4, score: 999, is_public: true }
    newMatch.score = 69;
    db.table("match_result").update(newMatch);

    // ...
});
0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago