Skip to content

Commit 7a80e2f

Browse files
committed
fix typos
1 parent 7273938 commit 7a80e2f

5 files changed

Lines changed: 34 additions & 90 deletions

File tree

LICENSE

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -617,58 +617,3 @@ reviewing courts shall apply local law that most closely approximates
617617
an absolute waiver of all civil liability in connection with the
618618
Program, unless a warranty or assumption of liability accompanies a
619619
copy of the Program in return for a fee.
620-
621-
END OF TERMS AND CONDITIONS
622-
623-
How to Apply These Terms to Your New Programs
624-
625-
If you develop a new program, and you want it to be of the greatest
626-
possible use to the public, the best way to achieve this is to make it
627-
free software which everyone can redistribute and change under these terms.
628-
629-
To do so, attach the following notices to the program. It is safest
630-
to attach them to the start of each source file to most effectively
631-
state the exclusion of warranty; and each file should have at least
632-
the "copyright" line and a pointer to where the full notice is found.
633-
634-
<one line to give the program's name and a brief idea of what it does.>
635-
Copyright (C) <year> <name of author>
636-
637-
This program is free software: you can redistribute it and/or modify
638-
it under the terms of the GNU General Public License as published by
639-
the Free Software Foundation, either version 3 of the License, or
640-
(at your option) any later version.
641-
642-
This program is distributed in the hope that it will be useful,
643-
but WITHOUT ANY WARRANTY; without even the implied warranty of
644-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645-
GNU General Public License for more details.
646-
647-
You should have received a copy of the GNU General Public License
648-
along with this program. If not, see <https://www.gnu.org/licenses/>.
649-
650-
Also add information on how to contact you by electronic and paper mail.
651-
652-
If the program does terminal interaction, make it output a short
653-
notice like this when it starts in an interactive mode:
654-
655-
<program> Copyright (C) <year> <name of author>
656-
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657-
This is free software, and you are welcome to redistribute it
658-
under certain conditions; type `show c' for details.
659-
660-
The hypothetical commands `show w' and `show c' should show the appropriate
661-
parts of the General Public License. Of course, your program's commands
662-
might be different; for a GUI interface, you would use an "about box".
663-
664-
You should also get your employer (if you work as a programmer) or school,
665-
if any, to sign a "copyright disclaimer" for the program, if necessary.
666-
For more information on this, and how to apply and follow the GNU GPL, see
667-
<https://www.gnu.org/licenses/>.
668-
669-
The GNU General Public License does not permit incorporating your program
670-
into proprietary programs. If your program is a subroutine library, you
671-
may consider it more useful to permit linking proprietary applications with
672-
the library. If this is what you want to do, use the GNU Lesser General
673-
Public License instead of this License. But first, please read
674-
<https://www.gnu.org/licenses/why-not-lgpl.html>.

README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
Sqlite ORM for deno. Tables with relations are not supporeted.
1+
Sqlite ORM for deno. Tables with relations are not supported.
22

33
#### Usage
44
**Create an instance of the ORM:**
55
```typescript
6-
import { SqliteOrm, SqlTable } from 'https://raw.githubusercontent.com/Blockzilla101/deno-sqlite-orm/0.5.2/mod.ts';
6+
import { SqliteOrm, SqlTable } from 'https://deno.land/x/deno_sqlite_orm@0.5.2/mod.ts';
77
const orm = new SqliteOrm({
88
dbPath: 'path/to/database.db'
99
});
1010
```
11-
You can access the database instance directly by `orm.db`. If you are using an existing database and it contains JSON objects, enable `jsonCompatMode` in options or objects similar to:
11+
You can access the database instance directly by `orm.db`. If you are using an existing database and it contains JSON objects, enable `jsonCompatMode` in options or objects similar to following will not be parsed.
1212
```json
1313
{
1414
"foo": "baz",
1515
"bar": 0
1616
}
1717
```
18-
will not be parsed.<br>
1918

2019
**Create a model:**
2120
```typescript
@@ -26,11 +25,10 @@ class Foo extends SqlTable {
2625
```
2726
Incase `Foo` exists in the database but has a different name, use `@orm.model('bar')`. All Tables have `id` as a primary key.
2827
It can be removed by overriding it and using `@orm.ignoreColumn()`. Tables are created if they don't exist. If new columns
29-
are added, the table is altered. If a column is removed from the model, it still stays in the database. If you want to renamed
30-
a column use `@orm.mappedTo('oldName')`
28+
are added, the table is altered. If a column is removed from the model, it still stays in the database. If you want to rename the property, or the column exists with a different name use `@orm.mappedTo('oldName')`
3129

3230
**Defining columns:**<br>
33-
All properties of the table are considered as columns. Column types are autmatically inferred from the default value<br>
31+
All properties of the table are considered as columns. Column types are automatically inferred from the default value<br>
3432
of the property.
3533
```typescript
3634
class Foo extends SqlTable {
@@ -39,7 +37,7 @@ class Foo extends SqlTable {
3937
// type is automatically inferred as "string"
4038
public foo = 'bar'
4139

42-
// column type is required when property doesnt have a default value
40+
// column type is required when property doesn't have a default value
4341
@orm.columnType('string')
4442
public bar!: string
4543

@@ -65,7 +63,7 @@ class Foo extends SqlTable {
6563
@orm.mappedTo('bar')
6664
public baa = ''
6765

68-
// if you dont want to stack multiple decorators, you can do:
66+
// if you don't want to stack multiple decorators, you can do:
6967
@orm.column({ type: 'string', nullable: true })
7068
public faz!: string | null
7169
}
@@ -86,7 +84,7 @@ orm.findOne(Foo, {
8684
// you can check if its new from `Foo._new`
8785
orm.findOneOptional(Foo, 1)
8886

89-
// same as `findOne` but returns multiple instanceof/rows of Foo
87+
// same as `findOne` but returns multiple instances of or rows of Foo
9088
orm.findMany(Foo, {
9189
where: {
9290
clause: 'id > 5'
@@ -126,27 +124,28 @@ orm.aggregateSelect<[foo: string, count: number]>(Foo, {
126124
127125
**Saving objects:**<br>
128126
Objects are converted to JSON before saving, and parsed when read. If its a class instance then the class should be registered
129-
by `@registerJsonSerializabe()`
127+
by `@registerJsonSerializable()`
130128
```typescript
131-
import { registerJsonSerializabe } from 'https://raw.githubusercontent.com/Blockzilla101/deno-sqlite-orm/0.5.2/mod.ts';
129+
import { registerJsonSerializable } from 'https://deno.land/x/deno_sqlite_orm@0.5.2/mod.ts';
132130

133-
@registerJsonSerializabe(['ignored'])
131+
// the property "ignored" will be ignored and not saved
132+
@registerJsonSerializable(['ignored'])
134133
class Bar {
135134
public foo = 'bar'
136135
public ignored = ''
137136
}
138137

139138
@orm.model()
140139
class Foo extends SqlTable {
141-
// type is autmatically inferred as json
140+
// type is automatically inferred as json
142141
bar: Record<string, any> = {}
143142
baz: Bar = new Bar()
144143
}
145144
```
146145
147146
##### Example
148147
```typescript
149-
import { SqliteOrm, SqlTable } from 'https://raw.githubusercontent.com/Blockzilla101/deno-sqlite-orm/0.5.2/mod.ts';
148+
import { SqliteOrm, SqlTable } from 'https://deno.land/x/deno_sqlite_orm@0.5.2/mod.ts';
150149
const orm = new SqliteOrm({
151150
dbPath: 'path/to/database.db',
152151
});

mod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export { SqliteOrm, SqlTable } from './src/orm.ts'
2-
export { registerJsonSerializabe } from './src/json.ts'
2+
export { registerJsonSerializable } from './src/json.ts'
33
export * from './src/errors.ts'

src/json.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { decode, encode } from 'https://deno.land/std@0.178.0/encoding/base64.ts';
1+
import { decode, encode } from 'https://deno.land/std@0.192.0/encoding/base64.ts';
22

33
const serializableClasses: {
44
classRef: new () => any;
55
ignoredProps: string[];
66
}[] = [];
77

8-
export function registerJsonSerializabe(ignoredProps: string[] = []) {
8+
export function registerJsonSerializable(ignoredProps: string[] = []) {
99
return (clas: new () => any) => {
1010
serializableClasses.push({
1111
classRef: clas,
@@ -14,7 +14,7 @@ export function registerJsonSerializabe(ignoredProps: string[] = []) {
1414
};
1515
}
1616

17-
function isSerializabe(obj: any): boolean {
17+
function isSerializable(obj: any): boolean {
1818
return typeof obj !== 'bigint' && typeof obj !== 'function' && typeof obj !== 'symbol';
1919
}
2020

@@ -123,7 +123,7 @@ export function jsonify(obj: Record<string, any> | any[], ignoredProps: string[]
123123
if (obj instanceof Array) {
124124
const parsed: any[] = [];
125125
for (const item of obj) {
126-
if (!isSerializabe(item)) continue;
126+
if (!isSerializable(item)) continue;
127127
parsed.push(writeValue(item));
128128
}
129129
return parsed;
@@ -132,7 +132,7 @@ export function jsonify(obj: Record<string, any> | any[], ignoredProps: string[]
132132
// parse objects
133133
const parsed: Record<string, any> = {};
134134
for (const [key, value] of Object.entries(obj)) {
135-
if (!isSerializabe(value)) continue;
135+
if (!isSerializable(value)) continue;
136136
if (ignoredProps.includes(key)) continue;
137137
parsed[key] = writeValue(value);
138138
}

src/orm.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { buildAggregateQuery, buildAlterQuery, buildCountWhereQuery, buildDelete
33
import { DBInvalidData, DBInvalidTable, DBModelNotFound, DBNotFound } from './errors.ts';
44
import { dejsonify, jsonify } from './json.ts';
55
import { prettyPrintDiff } from './util.ts';
6-
import { basename, join } from 'https://deno.land/std@0.178.0/path/mod.ts';
6+
import { basename, join } from 'https://deno.land/std@0.192.0/path/mod.ts';
77

88
interface OrmOptions {
99
/**
@@ -36,7 +36,7 @@ interface OrmOptions {
3636
* Set to true if you are using an existing database that contains JSON.
3737
* The library uses a custom parser to write maps and other class instances
3838
* so that it can read them as the class instance. (Custom classes should be
39-
* registered with `@registerJsonSerializabe()`)
39+
* registered with `@registerJsonSerializable()`)
4040
*/
4141
jsonCompatMode?: boolean;
4242
}
@@ -54,7 +54,7 @@ export interface TableColumn {
5454
*/
5555
type: ColumnType;
5656
/**
57-
* Name of column, preferrably same as one in the sqlite database.
57+
* Name of column, preferably same as one in the sqlite database.
5858
*/
5959
name: string;
6060
/**
@@ -131,17 +131,17 @@ export class Model {
131131
}
132132

133133
const gitBranch = new TextDecoder().decode(
134-
await Deno.run({
135-
cmd: ['git', 'branch', '--show-current'],
134+
new Deno.Command('git', {
135+
args: ['branch', '--show-current'],
136136
stdout: 'piped',
137-
}).output(),
137+
}).outputSync().stdout,
138138
).trim();
139139

140140
const gitCommit = new TextDecoder().decode(
141-
await Deno.run({
142-
cmd: ['git', 'rev-parse', 'HEAD'],
141+
new Deno.Command('git', {
142+
args: ['rev-parse', 'HEAD'],
143143
stdout: 'piped',
144-
}).output(),
144+
}).outputSync().stdout,
145145
).trim();
146146

147147
export class SqliteOrm {
@@ -223,7 +223,7 @@ export class SqliteOrm {
223223

224224
const parsed = new table();
225225
for (const col of this.models[table.name].columns) {
226-
(parsed as Record<string, unknown>)[col.name] = this.deseralize(found[col.mappedTo ?? col.name], col.type);
226+
(parsed as Record<string, unknown>)[col.name] = this.deserialize(found[col.mappedTo ?? col.name], col.type);
227227
}
228228
parsed._new = false;
229229

@@ -252,7 +252,7 @@ export class SqliteOrm {
252252
for (const datum of data) {
253253
const parsed = new table();
254254
for (const col of this.models[table.name].columns) {
255-
(parsed as Record<string, unknown>)[col.name] = this.deseralize(datum[col.mappedTo ?? col.name], col.type);
255+
(parsed as Record<string, unknown>)[col.name] = this.deserialize(datum[col.mappedTo ?? col.name], col.type);
256256
}
257257
parsed._new = false;
258258
parsedAll.push(parsed);
@@ -314,7 +314,7 @@ export class SqliteOrm {
314314
//#region decorators
315315

316316
/**
317-
* Explicity set column type for a model otherwised inferred from default value.
317+
* Explicity set column type for a model otherwise its inferred from default value.
318318
* @param type type of table column
319319
* @param nullable whether column can have a null value, defaults to true when property value is `undefined` or `null`
320320
*/
@@ -432,7 +432,7 @@ export class SqliteOrm {
432432
this.models[model.name] = builtModel;
433433
this.tempModelData = [];
434434

435-
// create table if it doesnt exist
435+
// create table if it doesn't exist
436436
const info = this.db.prepare(`PRAGMA table_info('${model.name}')`).all();
437437
if (info.length === 0) {
438438
this.hasModelChanges = true;
@@ -640,7 +640,7 @@ export class SqliteOrm {
640640
}
641641
}
642642

643-
private deseralize(data: any, type: ColumnType) {
643+
private deserialize(data: any, type: ColumnType) {
644644
if (data == null) return null;
645645
switch (type) {
646646
case 'boolean': {

0 commit comments

Comments
 (0)