Skip to content

Hoyasumii/palmdb

Repository files navigation

Collections -> Entities

Collection -> Schema -> Propperty

// palm.config.ts
await palm.start({
  logging: boolean,
  secret: "",
  collections: {
    users: schema({
      name: string({ }),
      email: string({ unique: true }),
      password: string({ }),
    }),
    brand: schema({
      name: string({ }),
      logo: string({ }),
    }),
    category: schema({
      name: string({ }),
      parentCategoryId: string({ nullable: true, default: null }),
    })
    products: schema({
      productName: string({  }),
      brandId: string({  }),
      categoryId: string({  }),
      price: number({  }),
      stock: number({ }),
    }),
    selectedProduct: schema({
      productId: string({ }),
      amount: number({ })
    })
    cart: schema({
      userId: string({ unique: true }),
      selectedProductsId: array({ }),
    }),
    address: schema({
      userId: string({ }),
      cep: string({ }),
      number: string({ }),
      additionalInfo: string({ }),
    }),
    order: schema({
      userId: string({ }),
      addressId: string({ }),
      orderDetailsId: string({ }),
      totalPrice: number({ }),
      trackingCode: string({ }),
      status: enum([
        "PENDING",
        "CONFIRMED",
        "PROCESSING",
        "SHIPPED",
        "DELIVERED",
        "CANCELLED",
        "RETURNED"
      ]),
    }),
    orderDetails: schema({
      userId: string({ }),
      selectedProductsId: array({ }),
      price: number({ }),
    }),
  },
  rules: {
    users: {
      "on-create": () => {
        bliblibli
      },
      "on-remove": () => {
        blobloblo
      }
    }
  }
})

// Uso do palm
const usersCollection = await palm.pick("users");

// await usersCollections.filter()

await usersCollection.find.unique("id");

// Como seria o enum:
enum([]);

.temp/palm/unique_keys//.jsonl .temp/palm/cache/specs.jsonl


.temp/palm/cache/<GROUP_ALIAS>/config .temp/palm/cache/<GROUP_ALIAS>/config.jsonl .temp/palm/collections//.jsonl .temp/palm/collections//group/.jsonl

Vai ter 2 diretórios:

  1. .palm -> database normal
  2. /tmp/.palm/* -> database que abstrai do .palm no intuito de memoizar resultados de processos, como locks e caches de grupos

collection.create collection.find collection.update collection.remove

collection.group.create(name, filter, refresh?: { days?: number, hours?: number, minutes?: number, seconds?: number }) collection.group.find(groupName) collection.group.update(groupName, data) collection.group.remove(groupName)

About

Local NoSQL database with type safety and lock concurrency control for TypeScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors