npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vika-orm

v0.6.3

Published

a sheetdb sdk for vika/lark

Downloads

281

Readme

vika-orm

简介

维格表vika的ts ORM

快速开始

npm i
npm run start

使用

  1. 安装依赖
npm i vika-orm
  1. 示例代码
import { log } from 'console'
import { BaseEntity, VikaOptions, MappingOptions, wait } from 'vika-orm' // 导入 BaseEntity, VikaOptions, 和 MappingOptions 类型/类
import { v4 as uuidv4 } from 'uuid'

async function main () {
  const vikaOptions: VikaOptions = {  // 定义 Vika API 的选项
    apiKey: '替换为你自己的vika token',  // vika API 密钥
    baseId: '替换为你自己的表id',  // 设置 base ID
  }

  const mappingOptions: MappingOptions = {  // 定义字段映射选项
    fieldMapping: {  // 字段映射
      email: 'Email',
      id: 'ID',
      name: 'Name',
    },
    tableName: 'users',  // 表名
  }

  /**
       * 用户实体
       */
  class User extends BaseEntity {  // 用户类继承 BaseEntity

    name?: string  // 定义名字属性,可选
    email?: string  // 定义电子邮件属性,可选
    id?:string

    // protected static override recordId: string = ''  // 定义记录ID,初始为空字符串

    protected static override mappingOptions: MappingOptions = mappingOptions  // 设置映射选项为上面定义的 mappingOptions

    protected static override getMappingOptions (): MappingOptions {  // 获取映射选项的方法
      return this.mappingOptions  // 返回当前类的映射选项
    }

    static override setMappingOptions (options: MappingOptions) {  // 设置映射选项的方法
      this.mappingOptions = options  // 更新当前类的映射选项
    }

  }

  User.setVikaOptions(vikaOptions)  // 设置 Vika API 选项

  // 使用示例

  // 增
  const newUser1 = new User()  // 创建一个新的用户实例
  newUser1.name = 'Bob'  // 设置用户名为 Bob
  newUser1.email = '[email protected]'  // 设置用户电子邮件为 [email protected]
  newUser1.id = uuidv4()
  const res = await newUser1.save()  // 保存用户实例
  log('保存newUser1:', JSON.stringify(res))  // 输出新用户的信息
  await wait(500)  // 等待 500 毫秒

  // 增
  const newUser2 = await User.create<User>({  // 创建一个新的用户
    email: '[email protected]',  // 用户电子邮件为 [email protected]
    id:uuidv4(),
    name: 'Test',  // 用户名为 Test
  })

  log('保存newUser2:', JSON.stringify(newUser2))  // 输出新用户的信息
  await wait(500)  // 等待 500 毫秒

  // 改
  const updateRes = await User.update(newUser2.recordId, { email: '[email protected]' } as Partial<User>)  // 更新新用户的电子邮件
  log('更新newUser2:', JSON.stringify(updateRes))  // 输出更新后的新用户信息
  await wait(500)  // 等待 500 毫秒

  // 查
  const queryRes = await User.findById(newUser2.recordId)
  log('查询findById:', JSON.stringify(queryRes))  // 输出更新后的新用户信息
  await wait(500)  // 等待 500 毫秒

  const query2Res = await User.findByField('email', '[email protected]')
  log('查询findByField:', JSON.stringify(query2Res))  // 输出更新后的新用户信息
  await wait(500)  // 等待 500 毫秒

  // 删
  const deleteRes = await User.delete(newUser2.recordId)  // 删除新用户
  log('删除newUser2:', JSON.stringify(deleteRes))  // 输出更新后的新用户信息
  await wait(500)  // 等待 500 毫秒

  // 查
  const users = await User.findAll()  // 查找所有用户(当前被注释掉)
  log('查询users:', JSON.stringify(users))  // 输出新用户的信息
  await wait(500)  // 等待 500 毫秒
}

(async function () {
  await main()
})().catch(error => {
  console.error(error)
})

历史版本

v0.1.1 (2023-10-7)

  1. 初始化创建代码库及npm包