![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
A Powerful MySQL ORM. Epic SQL allows you to build applications by writing less code without a single line of SQL Query!
Epic SQL is very easy to use library. View the documentation below to start working with Epic SQL quickly!
Following are the available datatypes in the ORM.
Following is the example of a Users Schema.
import { Schema, SQLBoolean, SQLEnum, SQLNumber, SQLString } from "epic-sql";
export const Users = new Schema("users", {
userId: new SQLString({
isSearchable: true, // Add Match Against Index
isUnique: true,
}),
name: new SQLString({
isSearchable: true, // Add Match Against Index
}),
isVerified: new SQLBoolean({
defaultValue: false,
}),
status: new SQLEnum(["Active", "Blocked"], {
isSearchable: true, // Add Match Against Index
defaultValue: "Active",
}),
createdOn: new SQLNumber({
defaultValue: Date.now(),
}),
modifiedOn: new SQLNumber({
defaultValue: Date.now(),
updatedValue: Date.now(), // Timestamp is updated if any record changes.
}),
} as const);
Follow the method below to create a Connection with MySql Server.
import { Connector, ConnectionManager } from "epic-sql";
// Import All Schemas
import { Users } from "./schema/users";
import { Profiles } from "./schema/profiles";
import { Orders } from "./schema/orders";
(async () => {
// Create and Initialize a Connection Manager Instance.
const Connection = await new ConnectionManager(
// You need to pass a Connector Instance to Connection Manager.
new Connector(
{
host: "localhost",
user: "root",
password: "",
database: "mydatabase",
},
{
/**
* Schema will be synced to the MySql Server on each connection if sync is set to True.
* Please don't forget to set it to False on the production.
*/
sync: false,
// Prints each exectued SQL Query in the Console.
logs: true,
}
),
// Pass all Schemas to the Connection Manager.
[Users, Profiles, Orders]
).init();
// End the Connection
Connection.getConnector().end();
})();
Follow the method below to insert data to Users Schema we created just now.
import { Users } from "./schema/users";
(async () => {
// Create a Locked Users Schema by calling new() method on it.
// It is required to Lock the Schema before doing any CRUD operation on it.
const User = Users.new();
// Insert Row to Users Schema
// If there is a problem, the operation will throw an error.
// You can insert one row passed as an object or multiple rows passed as an Array.
const NewUser = await User.insert({
userId: "john",
name: "John Doe",
isVerified: true,
status: "Active",
});
// If the operation was successful, A new User object will be stored on NewUser variable.
console.log(NewUser);
/**
* Will Print:
*
* {
* _id: 1,
* userId: "john",
* name: "John Doe",
* isVerified: true,
* status: "Active",
* createdOn: 356210359812,
* modifiedOn: 356210359812,
* }
*
*/
})();
Follow the method below to fetch data from Users Schema.
import { Users } from "./schema/users";
(async () => {
// Example 1:
// Select all Users from Users Schema.
// Use select() method for selection.
console.log(
await Users.new()
// You can pass an Array of column names that you want to select.
.select(["userId", "name", "status"])
);
/**
* Will Print:
*
* [
* {
* userId: "john",
* name: "John Doe",
* status: "Active",
* }
* ]
*
*/
// Example 2:
// Select One User where userId is "john"
console.log(
await Users.new()
.where({
userId: "john",
})
.selectOne()
);
/**
* Will Print:
*
* {
* _id: 1,
* userId: "john",
* name: "John Doe",
* isVerified: true,
* status: "Active",
* createdOn: 356210359812,
* modifiedOn: 356210359812,
* }
*
*/
// Exmaple 3:
// Advance Data Selection
const SpecialUsers = await Users.new()
.where({
isVerified: true,
status: "Active",
})
// Extra Conditions
.having({
_id: {
// _id Ranges Between 1 to 100
BT: [1, 100],
},
})
// Set Selection Offset
.offset(0)
// Set Selection Limit
.limit(10)
// Set Selection Sorting ASC or DESC
.sort("DESC")
.select();
// Example 4:
// Search Data
const SearchedUsers = await Users.new()
// Search your data using Match Against feature
// Make sure you have set isSearchable to True on the Schema for the columns you want to search.
// In our case userId, name and status column is searchable.
// You cannot use where() method with search() method.
.search("my search string")
.select();
})();
Follow the method below to update data on Users Schema.
import { Users } from "./schema/users";
(async () => {
// Example 1:
// Update User Status
// Use update() method to update User Data
await Users.new().where({ userId: "john" }).update({
status: "Blocked",
});
// Example 2:
// Update User Status, use updateOrFail() method to throw error if nothing has been updated.
await Users.new().where({ userId: "john" }).updateOrFail({
status: "Blocked",
});
})();
Follow the method below to delete data from Users Schema.
import { Users } from "./schema/users";
(async () => {
// Example 1:
// Delete a User
// Use delete() method to delete User Data
await Users.new().where({ userId: "john" }).delete();
// Example 2:
// Delete a User, use deleteOrFail() method to throw error if nothing has been deleted.
await Users.new().where({ userId: "john" }).deleteOrFail({
status: "Blocked",
});
})();
I hope that the documentation is easy enough to understand the library. You will find it very easy to work with and will be able to explore more features while using this library.
We are still working on the documentation, there are allot of features missing in the documentation but available on the library. We will add them to the docs soon.
Good Luck!
FAQs
A Simple But Powerful SQL ORM!!!
The npm package epic-sql receives a total of 0 weekly downloads. As such, epic-sql popularity was classified as not popular.
We found that epic-sql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.