detaorm 1.0.0 → 1.2.0

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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "deta": "^1.1.0",
4
+ "detaorm": "^1.0.0",
4
5
  "prisma": "^4.2.1",
5
6
  "ts-node": "^10.9.1"
6
7
  },
7
8
  "name": "detaorm",
8
- "version": "1.0.0",
9
+ "version": "1.2.0",
9
10
  "main": "index.js",
10
- "devDependencies": {},
11
11
  "scripts": {},
12
12
  "keywords": [],
13
13
  "author": "",
package/src/index.js DELETED
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Orm = exports._Base = exports.Schema = void 0;
4
- const deta_1 = require("deta");
5
- class Schema {
6
- constructor(config) {
7
- this.config = config;
8
- }
9
- }
10
- exports.Schema = Schema;
11
- class _Base {
12
- constructor(config) {
13
- this.config = config;
14
- }
15
- }
16
- exports._Base = _Base;
17
- class Orm {
18
- constructor(config) {
19
- this.config = config;
20
- this.deta = (0, deta_1.Deta)(this.config.projectKey);
21
- }
22
- getrepo(_base) {
23
- return new _getrepo(_base, this.deta);
24
- }
25
- }
26
- exports.Orm = Orm;
27
- class _getrepo {
28
- constructor(base, deta) {
29
- this.base = base;
30
- this.deta = deta;
31
- this._db = this.deta.Base(this.base.config.name);
32
- }
33
- create(data) {
34
- return this._db.insert(data);
35
- }
36
- findOne(q) {
37
- return this._db.fetch(q);
38
- }
39
- findOneById(key) {
40
- return this._db.get(key);
41
- }
42
- update(key, data) {
43
- return this._db.update(data, key);
44
- }
45
- delet(key) {
46
- return this._db.delete(key);
47
- }
48
- }
package/src/index.ts DELETED
@@ -1,59 +0,0 @@
1
- import _Deta, { Deta, Base } from "deta";
2
- import fs from "fs";
3
-
4
- // import Deta from "deta/dist/types/deta";
5
-
6
- import { key, t, schemsType } from "./types";
7
-
8
- export class Schema {
9
- constructor(
10
- public config: {
11
- [keys in string]: {
12
- type: t;
13
- defualt?: any;
14
- unique?: boolean;
15
- };
16
- }
17
- ) {}
18
- }
19
- export class _Base {
20
- constructor(public config: { name: string; schema: Schema }) {}
21
- }
22
-
23
- export class Orm {
24
- private deta = Deta(this.config.projectKey);
25
-
26
- constructor(
27
- private config: {
28
- projectKey: string;
29
- }
30
- ) {}
31
-
32
- getrepo(_base: _Base) {
33
- return new _getrepo(_base, this.deta);
34
- }
35
- }
36
-
37
- class _getrepo {
38
- _db: ReturnType<typeof Base>;
39
-
40
- constructor(private base: _Base, private deta: ReturnType<typeof Deta>) {
41
- this._db = this.deta.Base(this.base.config.name);
42
- }
43
-
44
- create(data: any) {
45
- return this._db.insert(data);
46
- }
47
- findOne(q: any) {
48
- return this._db.fetch(q);
49
- }
50
- findOneById(key: any) {
51
- return this._db.get(key);
52
- }
53
- update(key: any, data: any) {
54
- return this._db.update(data, key);
55
- }
56
- delet(key: any) {
57
- return this._db.delete(key);
58
- }
59
- }
package/src/text.js DELETED
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const index_1 = require("./index");
13
- const ss = new index_1.Schema({
14
- name: {
15
- type: "String",
16
- },
17
- username: {
18
- type: "String",
19
- },
20
- });
21
- const b = new index_1._Base({
22
- name: "User",
23
- schema: ss,
24
- });
25
- const orm = new index_1.Orm({
26
- projectKey: "b0tpjji4_cDJhctRv4UEoYgcgQgC9qC6nnNhyUXWt",
27
- });
28
- (() => __awaiter(void 0, void 0, void 0, function* () {
29
- return console.log(yield orm.getrepo(b).create({
30
- name: "parag",
31
- }));
32
- }))();
package/src/text.ts DELETED
@@ -1,24 +0,0 @@
1
- import { Orm, Schema, _Base } from "./index";
2
-
3
- const ss = new Schema({
4
- name: {
5
- type: "String",
6
- },
7
- username: {
8
- type: "String",
9
- },
10
- });
11
- const b = new _Base({
12
- name: "User",
13
- schema: ss,
14
- });
15
- const orm = new Orm({
16
- projectKey: "b0tpjji4_cDJhctRv4UEoYgcgQgC9qC6nnNhyUXWt",
17
- });
18
-
19
- (async () =>
20
- console.log(
21
- await orm.getrepo(b).create({
22
- name: "parag",
23
- })
24
- ))();
package/src/types.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export type key = any;
2
- export type t = "String" | "Number" | "boolean" | "array" | "object";
3
- export interface schemsType<T, k> {
4
- [key: typeof T]: typeof K;
5
- }