Skip to content

Commit aefddd0

Browse files
v0.7.1
1 parent 05582dc commit aefddd0

File tree

26 files changed

+448
-1464
lines changed

26 files changed

+448
-1464
lines changed

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ ENGINE_FLAGS = -std=c++2b
88

99
# PATH
1010
PATH_BIN = $(CURDIR)/build/index.so
11-
PATH_SRC = $(CURDIR)/src/cpp/ffi.cpp
12-
PATH_TESTS_BIN = $(CURDIR)/src/tests/bin/index
11+
PATH_SRC = $(CURDIR)/src/ffi.cpp
12+
PATH_TESTS_BIN = $(CURDIR)/src/tests/build/index
1313
PATH_TESTS_SRC = $(CURDIR)/src/tests/index.cpp
1414

1515
# INC
1616
INC_SRC = -I $(CURDIR)/src
17-
INC_CPP = -I $(CURDIR)/src/cpp
1817
INC_INCLUDE = -L /usr/include
1918
INC_JSONCPP = -I /usr/include/jsoncpp/json
2019

21-
INC = ${INC_SRC} ${INC_CPP} ${INC_INCLUDE} ${INC_JSONCPP}
20+
INC = ${INC_SRC} ${INC_INCLUDE} ${INC_JSONCPP}
2221

2322
# LINK
2423
LINK_JSONCPP = -ljsoncpp
@@ -31,7 +30,7 @@ build:
3130
${ENGINE_BUILD} ${ENGINE_FLAGS} ${INC} ${LINK} -fPIC -shared ${PATH_SRC} -o ${PATH_BIN}
3231

3332
test:
34-
clear && mkdir -p src/tests/bin && rm -rf src/tests/bin/*
33+
clear && mkdir -p src/tests/build && rm -rf src/tests/build/*
3534
${ENGINE_WATCH} $(ENGINE_FLAGS) $(PATH_TESTS_SRC) ${INC} ${LINK} -o $(PATH_TESTS_BIN) && $(PATH_TESTS_BIN)
3635

3736
.PHONY: build test

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<img src="https://static.wikia.nocookie.net/arnelify/images/c/c8/Arnelify-logo-2024.png/revision/latest?cb=20240701012515" style="width:336px;" alt="Arnelify Logo" />
22

3-
![Arnelify ORM for C++](https://img.shields.io/badge/Arnelify%20ORM%20for%20C++-0.6.3-yellow) ![C++](https://img.shields.io/badge/C++-2b-red) ![G++](https://img.shields.io/badge/G++-14.2.0-blue) ![C-Lang](https://img.shields.io/badge/CLang-14.0.6-blue)
3+
![Arnelify ORM for C++](https://img.shields.io/badge/Arnelify%20ORM%20for%20C++-0.7.1-yellow) ![C++](https://img.shields.io/badge/C++-2b-red) ![G++](https://img.shields.io/badge/G++-14.2.0-blue) ![C-Lang](https://img.shields.io/badge/CLang-14.0.6-blue)
44

55
## 🚀 About
66
**Arnelify® ORM for C++** - is a minimalistic dynamic library which is an ORM written in C and C++.
@@ -53,15 +53,17 @@ This software is licensed under the <a href="https://github.com/arnelify/arnelif
5353
Join us to help improve this software, fix bugs or implement new functionality. Active participation will help keep the software up-to-date, reliable, and aligned with the needs of its users.
5454

5555
## ⭐ Release Notes
56-
Version 0.6.3 - Minimalistic dynamic library
56+
Version 0.7.1 - Minimalistic dynamic library
5757

5858
We are excited to introduce the Arnelify ORM for C++ dynamic library! Please note that this version is raw and still in active development.
5959

6060
Change log:
6161

6262
* Minimalistic dynamic library
6363
* NodeJS (Bun) addon
64+
* Multi-Threading
6465
* FFI Support
66+
* Significant refactoring and optimizations
6567

6668
Please use this version with caution, as it may contain bugs and unfinished features. We are actively working on improving and expanding the ORM's capabilities, and we welcome your feedback and suggestions.
6769

src/cpp/addon.cpp renamed to src/addon.cpp

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,27 @@
88
#include "json.h"
99
#include "napi.h"
1010

11-
#include "index.cpp"
11+
#include "index.h"
1212

13-
ArnelifyORM* orm = nullptr;
13+
MySQL* mysql = nullptr;
1414

15-
Napi::Value orm_create(const Napi::CallbackInfo& args) {
15+
Napi::Value orm_mysql_connect(const Napi::CallbackInfo& args) {
16+
Napi::Env env = args.Env();
17+
18+
mysql->connect();
19+
20+
return env.Undefined();
21+
}
22+
23+
Napi::Value orm_mysql_close(const Napi::CallbackInfo& args) {
24+
Napi::Env env = args.Env();
25+
26+
mysql->close();
27+
28+
return env.Undefined();
29+
}
30+
31+
Napi::Value orm_mysql_create(const Napi::CallbackInfo& args) {
1632
Napi::Env env = args.Env();
1733
if (args.Length() < 1 || !args[0].IsString()) {
1834
Napi::TypeError::New(env,
@@ -34,10 +50,10 @@ Napi::Value orm_create(const Napi::CallbackInfo& args) {
3450
exit(1);
3551
}
3652

37-
const bool hasDriver =
38-
json.isMember("ORM_DRIVER") && json["ORM_DRIVER"].isString();
39-
if (!hasDriver) {
40-
std::cout << "[Arnelify ORM]: C++ error: 'ORM_DRIVER' is missing."
53+
const bool hasMaxConnections = json.isMember("ORM_MAX_CONNECTIONS") &&
54+
json["ORM_MAX_CONNECTIONS"].isInt();
55+
if (!hasMaxConnections) {
56+
std::cout << "[Arnelify ORM]: C++ error: 'ORM_MAX_CONNECTIONS' is missing."
4157
<< std::endl;
4258
exit(1);
4359
}
@@ -77,25 +93,25 @@ Napi::Value orm_create(const Napi::CallbackInfo& args) {
7793
exit(1);
7894
}
7995

80-
ArnelifyORMOpts opts(json["ORM_DRIVER"].asString(),
81-
json["ORM_HOST"].asString(), json["ORM_NAME"].asString(),
82-
json["ORM_USER"].asString(), json["ORM_PASS"].asString(),
83-
json["ORM_PORT"].asInt());
96+
MySQLOpts opts(json["ORM_MAX_CONNECTIONS"].asInt(),
97+
json["ORM_HOST"].asString(), json["ORM_NAME"].asString(),
98+
json["ORM_USER"].asString(), json["ORM_PASS"].asString(),
99+
json["ORM_PORT"].asInt());
84100

85-
orm = new ArnelifyORM(opts);
101+
mysql = new MySQL(opts);
86102

87103
return env.Undefined();
88104
}
89105

90-
Napi::Value orm_destroy(const Napi::CallbackInfo& args) {
106+
Napi::Value orm_mysql_destroy(const Napi::CallbackInfo& args) {
91107
Napi::Env env = args.Env();
92108

93-
delete orm;
94-
orm = nullptr;
109+
delete mysql;
110+
mysql = nullptr;
95111
return env.Undefined();
96112
}
97113

98-
Napi::Value orm_exec(const Napi::CallbackInfo& info) {
114+
Napi::Value orm_mysql_exec(const Napi::CallbackInfo& info) {
99115
Napi::Env env = info.Env();
100116
if (!info.Length() || !info[0].IsString()) {
101117
Napi::TypeError::New(env, "[Arnelify ORM]: C++ error: query is missing.")
@@ -129,8 +145,8 @@ Napi::Value orm_exec(const Napi::CallbackInfo& info) {
129145
bindings.emplace_back(value.asString());
130146
}
131147

132-
ArnelifyORMRes res = orm->exec(query, bindings);
133-
Json::Value json = orm->toJson(res);
148+
MySQLRes res = mysql->exec(query, bindings);
149+
Json::Value json = mysql->toJson(res);
134150

135151
Json::StreamWriterBuilder writer;
136152
writer["indentation"] = "";
@@ -140,16 +156,19 @@ Napi::Value orm_exec(const Napi::CallbackInfo& info) {
140156
return Napi::String::New(env, out);
141157
}
142158

143-
Napi::Value orm_get_uuid(const Napi::CallbackInfo& info) {
159+
Napi::Value orm_mysql_get_uuid(const Napi::CallbackInfo& info) {
144160
Napi::Env env = info.Env();
145-
return Napi::String::New(env, orm->getUuId());
161+
return Napi::String::New(env, mysql->getUuId());
146162
}
147163

148164
Napi::Object Init(Napi::Env env, Napi::Object exports) {
149-
exports.Set("orm_create", Napi::Function::New(env, orm_create));
150-
exports.Set("orm_destroy", Napi::Function::New(env, orm_destroy));
151-
exports.Set("orm_exec", Napi::Function::New(env, orm_exec));
152-
exports.Set("orm_get_uuid", Napi::Function::New(env, orm_get_uuid));
165+
exports.Set("orm_mysql_close", Napi::Function::New(env, orm_mysql_close));
166+
exports.Set("orm_mysql_connect", Napi::Function::New(env, orm_mysql_connect));
167+
exports.Set("orm_mysql_create", Napi::Function::New(env, orm_mysql_create));
168+
exports.Set("orm_mysql_destroy", Napi::Function::New(env, orm_mysql_destroy));
169+
exports.Set("orm_mysql_exec", Napi::Function::New(env, orm_mysql_exec));
170+
exports.Set("orm_mysql_get_uuid",
171+
Napi::Function::New(env, orm_mysql_get_uuid));
153172
return exports;
154173
}
155174

src/cpp/contracts/opts.hpp

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/cpp/contracts/res.hpp

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/cpp/mariadb/contracts/logger.hpp

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/cpp/mariadb/contracts/res.hpp

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)