Comparing version 0.1.1 to 0.1.2
@@ -16,3 +16,3 @@ "use strict"; | ||
} | ||
const tableName = entityMetadata.name || entityClass.constructor.name; | ||
const tableName = (entityMetadata === null || entityMetadata === void 0 ? void 0 : entityMetadata.name) || entityClass.constructor.name; | ||
const entityInstance = new entityClass(); | ||
@@ -19,0 +19,0 @@ const columns = []; |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ { |
{ | ||
"name": "lil-orm", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Lil ORM is a super lightweight SQLite ORM for Node.js. With its clear API, you can easily interact with SQLite databases.", | ||
@@ -35,2 +35,2 @@ "main": "dist/index.js", | ||
} | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
![ORM](https://github.com/scassius/lil-orm/assets/35706430/5fd46412-ea3d-40b8-a56a-20450e9e2986) | ||
# Lil ORM | ||
@@ -5,3 +7,3 @@ Lil ORM is a super lightweight SQLite ORM for Node.js. With its clear API, you can easily interact with SQLite databases | ||
# Install | ||
``` | ||
```shell | ||
npm i lil-orm | ||
@@ -11,3 +13,3 @@ ``` | ||
# Define Entity | ||
``` | ||
```typescript | ||
@Entity('user') | ||
@@ -63,6 +65,47 @@ class UserEntity { | ||
# Module Setup | ||
⚠️ **Warning: Important Configuration Required** | ||
To ensure proper functioning of the library, please make sure to configure your TypeScript project correctly. | ||
**Option 1: Enable `useDefineForClassFields`** | ||
In your project's `tsconfig.json`, add or modify the `compilerOptions` section to include the following: | ||
```json | ||
{ | ||
"compilerOptions": { | ||
"useDefineForClassFields": true | ||
} | ||
} | ||
``` | ||
import { LilORMModule } from 'lil-orm'; | ||
**Option 2: Initialize Every Property with Default Values** | ||
If you cannot enable `useDefineForClassFields` or prefer not to modify your TypeScript configuration, make sure to explicitly initialize every property in your entity class with a default value. | ||
For example: | ||
```typescript | ||
@Entity('tableName') | ||
class MyEntity { | ||
@PrimaryKey({ | ||
autoIncrement: true, | ||
}) | ||
@Column({ | ||
type: 'INTEGER' | ||
}) | ||
id: number = 0; | ||
@Column({ | ||
type: 'TEXT' | ||
}) | ||
name: string = ''; | ||
// ...other properties | ||
} | ||
``` | ||
# Module Setup | ||
```typescript | ||
import { LilORM } from 'lil-orm'; | ||
const databaseConnectionString = ':memory:'; | ||
@@ -76,3 +119,3 @@ | ||
(experimental API name) | ||
``` | ||
```typescript | ||
module.createTable(UserEntity) //to create a table from an entity | ||
@@ -82,3 +125,3 @@ ``` | ||
# CRUD Operations | ||
``` | ||
```typescript | ||
//get repository for DAO | ||
@@ -118,3 +161,3 @@ const repository = module.getRepository<UserEntity>(UserEntity); | ||
# Transactions | ||
``` | ||
```typescript | ||
import { Transaction } from 'lil-orm'; | ||
@@ -121,0 +164,0 @@ |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
180
84783
50
931