Skip to content

Commit

Permalink
v0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissmejia committed Sep 23, 2018
1 parent 3213d10 commit 3f0f35c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 13 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ usersTable.get({}).then((data: any) => {
});
```

Query result:
Query executed:
```sql
'SELECT `users`.`id`, `users`.`created`, `users`.`username`, `users`.`email`, `users`.`first_name`, `users`.`last_name`, `users`.`admin`, `users`.`verified`, `users`.`active` FROM `users` LIMIT 1;'
```
Expand Down Expand Up @@ -79,7 +79,7 @@ usersTable.getSome({
});
```

Query result:
Query executed:
```sql
'SELECT `users`.`id`, `users`.`created`, `users`.`username`, `users`.`email`, `users`.`first_name`, `users`.`last_name`, `users`.`admin`, `users`.`verified`, `users`.`active` FROM `users` LIMIT 3;'
```
Expand Down Expand Up @@ -116,7 +116,7 @@ usersTable.getAll({
});
```

Query result:
Query executed:
```sql
'SELECT `users`.`id`, `users`.`created`, `users`.`username`, `users`.`email`, `users`.`first_name`, `users`.`last_name`, `users`.`admin`, `users`.`verified`, `users`.`active` FROM `users` WHERE `users`.`id` = 3;'
```
Expand Down Expand Up @@ -147,7 +147,7 @@ usersTable.insert({
});
```

Query result:
Query executed:
```sql
'INSERT INTO `users` (`firstName`) VALUES (?);'
```
Expand All @@ -170,7 +170,7 @@ usersTable.update({
});
```

Query result:
Query executed:
```sql
'UPDATE `users` SET `firstName` = "Chriss" WHERE `users`.`id` = 3;'
```
Expand All @@ -195,7 +195,7 @@ usersTable.delete({
});
```

Query result:
Query executed:
```sql
'DELETE FROM `users` WHERE `users`.`id` = 1;'
```
Expand Down Expand Up @@ -231,7 +231,7 @@ sessionsTable.join([{
});
```

Query result:
Query executed:
```sql
SELECT `sessions`.`id`, `sessions`.`created`, `sessions`.`ip`, `sessions`.`user`, `users`.`username` AS `users__username`, `users`.`email` AS `users__email`, `users`.`firstName` AS `users__firstName`, `users`.`lastName` AS `users__lastName` FROM `sessions` LEFT JOIN `users` ON `sessions`.`user` = `users`.`id` WHERE `users`.`id` = 3;
```
Expand Down Expand Up @@ -263,7 +263,7 @@ sessionsTable.join([{
});
```

Query result:
Query executed:
```sql
UPDATE `sessions` INNER JOIN `users` ON `sessions`.`user` = `users`.`id` SET `ip` = "121.0.0.1" WHERE `users`.`id` = 3;
```
Expand All @@ -288,7 +288,7 @@ sessionsTable.join([{
});
```

Query result:
Query executed:
```sql
DELETE FROM `sessions` INNER JOIN `users` ON `sessions`.`user` = `users`.`id` WHERE `users`.`id` = 3;
```
Expand Down Expand Up @@ -316,9 +316,9 @@ sessionsTable.getAll({
});
```

Query result:
Query *prepared*:
```sql
SELECT `users`.`id`, `users`.`created`, `users`.`username`, `users`.`email`, `users`.`firstName` AS `first_name`, `users`.`lastName` AS `last_name`, `users`.`admin`, `users`.`verified`, `users`.`active` FROM `users` WHERE (`users`.`id` = ?) OR (`users`.`username` = 'chriss');
```

This can be helpful in some scenarios but is *not recomended*, only use it if you know what are you doing and *never*, send a parameter unprepared, you will expose your system to sql injection.
This can be helpful in some scenarios but is **not recomended**, only use it if you know what are you doing and **never**, send a parameter unprepared, you will expose your system to sql injection.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unicoderns/orm",
"version": "0.1.0",
"version": "0.1.1",
"description": "Unicoderns Object/Relational Mapping",
"author": {
"name": "Unicoderns SA",
Expand Down
23 changes: 23 additions & 0 deletions sources/tests/join.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,27 @@ describe('Joins', () => {
});
});
*/

/*
it('INNER join update usersTwo with literal from users', () => {
var expected = {
sql: 'SELECT `sessions`.`id`, `sessions`.`created`, `sessions`.`ip`, `sessions`.`user`, `users`.`username` AS `users__username`, `users`.`email` AS `users__email`, `users`.`firstName` AS `users__firstName`, `users`.`lastName` AS `users__lastName` FROM `sessions` LEFT JOIN `users` ON `sessions`.`user` = `users`.`id` WHERE `users`.`id` = ?;',
values: [3]
};
usersTwoTable.returnQuery().join([{
keyField: usersTwoTable.user,
fields: ["username"],
kind: "INNER"
}]).update({
data: {
username: "users__username"
},
where: "*"
}).then((query: Models.Query) => {
expect(query).toEqual(expected);
}).catch((err: any) => {
console.error(err)
});
});
*/
});
22 changes: 22 additions & 0 deletions tests/join.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/join.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3f0f35c

Please sign in to comment.