?? ? ????(OT ???? Habbo? ? ????)? ???? ??? ??? ?? Raw SQL? ??? ? ?????. ??? ???, ?? ??? ??? ??? ???? ? "?? ??" ???? ?? ???? ???? ???? ?? ?????. ????? ??? ???? ????? ?? ??? ???? ? ?? ??? ??? ??? ORM? ?? ??? ???? ??? ????.
??? ?? Raw SQL? ??? ?? ???????? ???? ?????? ?? ??? ??? ??????? ?????? ?????. ?? ?? ????? ???????. "? ??? ?????? ALTER TABLE? ???? ? ?? ?????." ? ?? ??? ?? ?????? ?? ????? "???? ???? ?? ?? ???? ????", "?? ? ???? ????????", "??? ???????"? ?? ? ?? ??? ?????. — ??? ?? ??? ??? ?? ????.
? ??? ?? ???
? ?? ??? ??? ?? ?? ?? ??? ?? ??? ? ???? ??? ?? ??? ??? ????? ??????. ?? ?? ?? ???? ???? ?? ????, ??????? ???? ? ? ???? ?????. ?? ?? ?? ?? ??? ??? ???? ? ?? ????? ???? ??? ?????. Kysely? ???? ?? ??? ??? ??? ??? TypeScript? ?? ?????. ???? ?? ??? ??????. ? lib? ?? ?? ??? ??? ??? Kysely? ??? ?? ?? ?? ?????? ????? ??? ? ?????? ????? ????? ???? ??????.
??? Kysely? ??? ? ?? ? ??? ? ??? ORM? ?? ???? ??? ??/?????? ?? ??? ??? ????. ? ?? ??? ???? ???? ??? ?? ??? ? ????. ???? ???? ?? PostgreSQL? ??? ?? ?????? ???? ? ??? Kanel? ??????. Kanel? ???? ?????? ??? ???? Kysely? ???? ?????.
?? Kanel?? Kysely? ?? ?? ??? ? ?? ?? ??? ????: Kanel-Kysely. ?? ? ???? ????? ???? ?????? ???? ?? ??, Zod ??? camelCase? ???? ?? ??? ?? ??? ?????.
Kysely ??
?? ?? ???? ?? NestJS? ???????. ??? ??? ?? ???? ??? ???? ??? ?? NestJS ???? ?? ?? ????. ? ???? ??? ??? JavaScript ????????. ?? JavaScript? "??"??? ???? ?? ?????. ??? ??? ? ?? ???? ?????.
??? ??? ???? ??? NestJS? ???? ???? ??? ???. ??? ???? ??? ??? ?? ????.
?? Kysely ??? CLI, Node.js? PostgreSQL ??? ???? ???.
npm i kysely pg && npm i kysely-ctl --save-dev
???? Kysely ???? ??? ?? ??? ???? ???. ?????? ? ?? ???? Knex ???? ???????.
// kysely.config.ts import "dotenv/config"; import { defineConfig, getKnexTimestampPrefix } from "kysely-ctl"; import { Pool } from "pg"; export default defineConfig({ dialect: "pg", dialectConfig: { pool: new Pool({ connectionString: process.env.DATABASE_URL }), }, migrations: { migrationFolder: "src/database/migrations", getMigrationPrefix: getKnexTimestampPrefix, }, seeds: { seedFolder: "src/database/seeds", getSeedPrefix: getKnexTimestampPrefix, }, });
???? ????? npx kysely migration make create_user_table ??? ???????. ? ?? ?????? ??? ?????. ????, ??? ??? ???? ???? ???? npx kysely migration late ??? ???? ???????? ? ??????? ?????.
// 20241225222128_create_user_table.ts import { sql, type Kysely } from 'kysely' export async function up(db: Kysely<any>): Promise<void> { await db.schema .createTable("user") .addColumn("id", "serial", (col) => col.primaryKey()) .addColumn("name", "text", (col) => col.notNull()) .addColumn("email", "text", (col) => col.unique().notNull()) .addColumn("password", "text", (col) => col.notNull()) .addColumn("created_at", "timestamp", (col) => col.defaultTo(sql`now()`).notNull(), ) .execute(); } export async function down(db: Kysely<any>): Promise<void> { await db.schema.dropTable("user").execute(); }
? ?? ??? ?????? ??????? ??? ??? ?????. ?? Kysely ????? ???? ?? camelCase? ???? ????.
// src/database/database.module.ts import { EnvService } from "@/env/env.service"; import { Global, Logger, Module } from "@nestjs/common"; import { CamelCasePlugin, Kysely, PostgresDialect } from "kysely"; import { Pool } from "pg"; export const DATABASE_CONNECTION = "DATABASE_CONNECTION"; @Global() @Module({ providers: [ { provide: DATABASE_CONNECTION, useFactory: async (envService: EnvService) => { const dialect = new PostgresDialect({ pool: new Pool({ connectionString: envService.get("DATABASE_URL"), }), }); const nodeEnv = envService.get("NODE_ENV"); const db = new Kysely({ dialect, plugins: [new CamelCasePlugin()], log: nodeEnv === "dev" ? ["query", "error"] : ["error"], }); const logger = new Logger("DatabaseModule"); logger.log("Successfully connected to database"); return db; }, inject: [EnvService], }, ], exports: [DATABASE_CONNECTION], }) export class DatabaseModule {}
?? ??
??? ???? ???????.
npm i kanel kanel-kysely --save-dev
???? Kanel? ??? ??? ? ??? ?? ??? ??? ?????. ?? camelCaseHook(?????? camelCase? ???? ??) ? kyselyTypeFilter(Kysely? ?????? ???? ???? ??)? ?? ?? ????? ??? ????. ??? ?? ? ??? ?? ???? ??? ?? ??? ?? ? ??? ?????. ? ???.
// .kanelrc.js require("dotenv/config"); const { kyselyCamelCaseHook, makeKyselyHook, kyselyTypeFilter } = require("kanel-kysely"); /** @type {import('kanel').Config} */ module.exports = { connection: { connectionString: process.env.DATABASE_URL, }, typeFilter: kyselyTypeFilter, preDeleteOutputFolder: true, outputPath: "./src/database/schema", preRenderHooks: [makeKyselyHook(), kyselyCamelCaseHook], };
??? ???? ????? npx kanel ??? ?????. ?? ??? ??? ??? ????? ???????. ? ????? ??? ??? ????, ? ???? Public?? ? ?? PublicSchema.ts ? User.ts?? ? ?? ? ??? ????. . User.ts? ??? ??? ?? ????:
// @generated // This file is automatically generated by Kanel. Do not modify manually. import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; /** Identifier type for public.user */ export type UserId = number & { __brand: 'UserId' }; /** Represents the table public.user */ export default interface UserTable { id: ColumnType<UserId, UserId | undefined, UserId>; name: ColumnType<string, string, string>; email: ColumnType<string, string, string>; password: ColumnType<string, string, string>; createdAt: ColumnType<Date, Date | string | undefined, Date | string>; } export type User = Selectable<UserTable>; export type NewUser = Insertable<UserTable>; export type UserUpdate = Updateable<UserTable>;
??? ?? ??? ?? ? ???? ??? Public ??, Database.ts ?????. Kysely? ??? ? ??? ? ??? ??? ??? ?????. ?? ??????? ?? ??. app.service.ts ?? ?? DatabaseModule ???? ???? Database.
??? Kysely? ?????.
npm i kysely pg && npm i kysely-ctl --save-dev
Kanel? ??? ??? ???? ????? ?????. ?? ???? ? ?? ???????? ??? ?? ???? ???? ?????.
?? ????
?? ????? ?? ?????(??? ?? ?) ?? ???? ?? ?????. ?? ??? ?? SQL? ???? ???? ????? "? ???" ??? ???? ?? ??? ?? ?? ?????. Kanel ??? ????? ??? ???? ???? ? ?? ??? ??? ? ?????. ? ? ??? ????? ??? ??? ?? ??? ?????, ?? ???? ??? ???.
??? ??: Frankenstein-nodejs
? ??? Kisley Kanel: ??? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

JavaScript? ??? ?? ????? ??? ?? ??? ??? ?? ?? ?? ????? ?? ???? ???? ?????. ??? ?? ???? ?? ??? ?? ??? ???? ???? ?? ?? ???? ???? ?????. ?? ??, ??? ? ?? ???? ??? (? : ??? null? ??) ?? ??? ????? ??????. ??? ??? ???? ??? ??? ????. closure?? ?? ??? ?? ??; ? ??? ??? ?? ?? ???? ?? ???? ????. V8 ??? ?? ???, ?? ??, ??/?? ???? ?? ??? ?? ??? ??? ????? ?? ??? ?? ??? ????. ?? ?? ???? ??? ??? ??? ??? ???? ????? ?? ?? ???? ?? ???????.

Node.js?? HTTP ??? ???? ? ?? ???? ??? ????. 1. ?? ????? ????? ??? ??? ? ?? ????? ?? ?? ? https.get () ??? ?? ??? ??? ? ?? ????? ?? ??? ?????. 2.axios? ??? ???? ? ?? ??????. ??? ??? ??? ??? ??? ??? ???/???, ?? JSON ??, ???? ?? ?????. ??? ?? ??? ????? ?? ????. 3. ?? ??? ??? ??? ??? ???? ???? ??? ??? ???? ?????.

JavaScript ??? ??? ?? ?? ? ?? ???? ????. ?? ???? ???, ??, ??, ?, ???? ?? ? ??? ?????. ?? ????? ?? ?? ? ? ??? ????? ?? ??? ??? ????. ??, ?? ? ??? ?? ?? ??? ??? ??? ???? ??? ??? ???? ??? ?? ??? ????. ?? ? ????? ??? ???? ? ??? ? ??? TypeofNull? ??? ?????? ??? ? ????. ? ? ?? ??? ???? ?????? ????? ???? ??? ???? ? ??? ? ? ????.

?????, JavaScript ???! ?? ? JavaScript ??? ?? ?? ?????! ?? ?? ??? ??? ??? ? ????. Deno?? Oracle? ?? ??, ??? JavaScript ?? ??? ????, Google Chrome ???? ? ??? ??? ???? ?????. ?????! Deno Oracle? "JavaScript"??? ????? Oracle? ?? ??? ??? ??????. Node.js? Deno? ??? ? Ryan Dahl? ??? ?????? ???? ????? JavaScript? ??? ???? Oracle? ????? ???? ?????.

?? JavaScript ??? ??? ??? ?????? ?? ??? ?? ?? ??? ?? ???? ????. 1. ??? ???? ???? ?? ??? ?? ? ? ???? ??? ??? ?? ? ?? ????? ?????. 2. Angular? ?????? ??? ?? ???? ? ?? ?? ??? ??? ??? ???? ?????. 3. VUE? ???? ?? ??? ???? ?? ?? ??? ?????. ?? ?? ?? ??, ? ??, ???? ???? ? SSR? ???? ??? ??? ??? ???? ? ??? ?????. ???, ??? ??? ??? ????? ????. ??? ??? ??? ??? ?? ????.

iife (?? invokedfunctionexpression)? ?? ??? ???? ?? ????? ??? ???? ?? ??? ????? ?? ??? ? ?????. ??? ?? ?? ??? ???? ? ?? ??? ??? ?? (function () {/code/}) ();. ?? ???? ??? ?????. 1. ?? ??? ??? ?? ???? ?? ??? ??? ?????. 2. ?? ??? ??? ???? ?? ?? ??? ????. 3. ?? ?? ??? ????? ?? ???? ???????? ?? ? ??. ???? ?? ???? ?? ??? ES6 ??? ??? ??? ?? ? ??? ????? ??? ? ???? ???????.

??? JavaScript?? ??? ??? ?????? ?? ???????. ?? ??, ?? ?? ? ??? ??? ?? ????? ????? ?????. 1. ?? ??? ??? ????? ???? ??. ()? ?? ??? ??? ?????. ?. ()? ?? ??? ?? ??? ??? ?? ? ? ????. 2. ?? ??? .catch ()? ???? ?? ??? ??? ?? ??? ??????, ??? ???? ???? ????? ??? ? ????. 3. Promise.all ()? ?? ????? (?? ?? ?? ? ??????? ??), Promise.Race () (? ?? ??? ?? ?) ? Promise.AllSettled () (?? ??? ???? ??)

Cacheapi? ?????? ?? ???? ??? ???? ???, ?? ??? ??? ?? ???? ? ??? ?? ? ???? ??? ??????. 1. ???? ????, ??? ??, ?? ?? ?? ???? ???? ??? ? ????. 2. ??? ?? ?? ??? ?? ? ? ????. 3. ?? ?? ?? ?? ?? ??? ??? ?? ?????. 4. ??? ???? ?? ?? ???? ?? ?? ?? ?? ?? ???? ?? ?? ??? ??? ? ????. 5. ?? ???? ??, ??? ??? ? ??? ??, ?? ??? ? ?? ???? ???? ???? ? ?? ?????. 6.?? ??? ?? ?? ?? ??, ???? ?? ? HTTP ?? ????? ?????? ???????.
