velocious 1.0.33 → 1.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# README
|
|
2
2
|
|
|
3
|
-
This is still work in progress.
|
|
4
|
-
|
|
5
3
|
* Concurrent multi threadded web server
|
|
6
4
|
* Database framework ala Rails
|
|
7
5
|
* Database models ala Rails
|
|
@@ -19,23 +17,29 @@ npm install velocious
|
|
|
19
17
|
npx velocious init
|
|
20
18
|
```
|
|
21
19
|
|
|
22
|
-
#
|
|
20
|
+
# Models
|
|
23
21
|
|
|
24
22
|
```bash
|
|
25
|
-
npx velocious g:
|
|
23
|
+
npx velocious g:model Account
|
|
24
|
+
npx velocious g:model Task
|
|
26
25
|
```
|
|
27
26
|
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
```
|
|
27
|
+
```js
|
|
28
|
+
import Record from "velocious/src/database/record/index.js"
|
|
31
29
|
|
|
32
|
-
|
|
30
|
+
class Task extends Record {
|
|
31
|
+
}
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
Task.belongsTo("account")
|
|
34
|
+
Task.translates("description", "subTitle", "title")
|
|
35
|
+
|
|
36
|
+
export default Task
|
|
36
37
|
```
|
|
37
38
|
|
|
38
39
|
# Migrations
|
|
40
|
+
|
|
41
|
+
Make a new migration from a template like this:
|
|
42
|
+
|
|
39
43
|
```bash
|
|
40
44
|
npx velocious g:migration create-tasks
|
|
41
45
|
```
|
|
@@ -66,7 +70,12 @@ export default class CreateEvents extends Migration {
|
|
|
66
70
|
}
|
|
67
71
|
```
|
|
68
72
|
|
|
69
|
-
Run migrations from
|
|
73
|
+
Run migrations from the command line like this:
|
|
74
|
+
```bash
|
|
75
|
+
npx velocious db:migrate
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Run migrations from anywhere if you want to:
|
|
70
79
|
|
|
71
80
|
```js
|
|
72
81
|
const migrationsPath = `/some/dir/migrations`
|
|
@@ -88,6 +97,8 @@ import {Task} from "@/src/models/task"
|
|
|
88
97
|
const tasks = await Task
|
|
89
98
|
.preload({project: {account: true}})
|
|
90
99
|
.where({projects: {public: true}})
|
|
100
|
+
.order("name")
|
|
101
|
+
.limit(5)
|
|
91
102
|
.toArray()
|
|
92
103
|
```
|
|
93
104
|
|
|
@@ -104,7 +115,7 @@ If you are developing on Velocious, you can run the tests with:
|
|
|
104
115
|
npm run test
|
|
105
116
|
```
|
|
106
117
|
|
|
107
|
-
# Writing a
|
|
118
|
+
# Writing a request test
|
|
108
119
|
|
|
109
120
|
First create a test file under something like the following path 'src/routes/accounts/create-test.js' with something like the following content:
|
|
110
121
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"velocious": "bin/velocious.js"
|
|
4
4
|
},
|
|
5
5
|
"name": "velocious",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.35",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test": "jasmine",
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
"sql-escape-string": "^1.1.0",
|
|
46
46
|
"sql.js": "^1.12.0",
|
|
47
47
|
"strftime": "^0.10.2",
|
|
48
|
-
"uuid": "^
|
|
48
|
+
"uuid": "^12.0.0"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Record from "../../../src/database/record/index.js"
|
|
2
|
+
|
|
3
|
+
class EventSeries extends Record {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
describe("Record - translations", () => {
|
|
7
|
+
it("handles difficult table names", async () => {
|
|
8
|
+
expect(EventSeries.getTranslationsTableName()).toEqual("event_series_translations")
|
|
9
|
+
})
|
|
10
|
+
})
|
|
@@ -14,9 +14,9 @@ export default class VelociousDatabaseQueryAlterTableBase extends QueryBase {
|
|
|
14
14
|
const sqls = []
|
|
15
15
|
|
|
16
16
|
for (const column of this.columns) {
|
|
17
|
-
let sql = `ALTER TABLE ${this.
|
|
17
|
+
let sql = `ALTER TABLE ${this.getOptions().quoteTableName(this.tableName)} ADD `
|
|
18
18
|
|
|
19
|
-
sql += this.
|
|
19
|
+
sql += this.getOptions().quoteColumnName(column.getName())
|
|
20
20
|
|
|
21
21
|
sqls.push(sql)
|
|
22
22
|
}
|
|
@@ -395,10 +395,9 @@ export default class VelociousDatabaseRecord {
|
|
|
395
395
|
const className = `${this.name}Translation`
|
|
396
396
|
const TranslationClass = class Translation extends VelociousDatabaseRecord {}
|
|
397
397
|
const belongsTo = `${inflection.camelize(inflection.singularize(this.tableName()), true)}`
|
|
398
|
-
const tableName = `${inflection.singularize(this.tableName())}_translations`
|
|
399
398
|
|
|
400
399
|
Object.defineProperty(TranslationClass, "name", {value: className})
|
|
401
|
-
TranslationClass.setTableName(
|
|
400
|
+
TranslationClass.setTableName(this.getTranslationsTableName())
|
|
402
401
|
TranslationClass.belongsTo(belongsTo)
|
|
403
402
|
|
|
404
403
|
this._translationClass = TranslationClass
|
|
@@ -407,7 +406,11 @@ export default class VelociousDatabaseRecord {
|
|
|
407
406
|
}
|
|
408
407
|
|
|
409
408
|
static getTranslationsTableName() {
|
|
410
|
-
|
|
409
|
+
const tableNameParts = this.tableName().split("_")
|
|
410
|
+
|
|
411
|
+
tableNameParts[tableNameParts.length - 1] = inflection.singularize(tableNameParts[tableNameParts.length - 1])
|
|
412
|
+
|
|
413
|
+
return `${tableNameParts.join("_")}_translations`
|
|
411
414
|
}
|
|
412
415
|
|
|
413
416
|
static async hasTranslationsTable() {
|