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 🙏

© 2026 – Pkg Stats / Ryan Hefner

worm.js

v1.0.2

Published

### 1.1 简介

Readme

Worm.js 文档

1.1 简介

Worm.js 是一个 ORM 框架,即一种将面向对象编程的思想引入到数据库模型的设计中的方法。

面向对象中编程的

"类" 对应数据库的 "表"   
"类的实例" 对应 "表的行"    
"类的属性" 对应 "表的字段"   
"属性的类型" 对应 "字段的类型"

这种数据库设计方式可以把面向对象良好的性质一起带来,规范化了一个大型系统中数据模型的设计模式,

因此十分建议使用 ORM 框架对网站的数据模型进行设计。

特别注意的是,本框架把"表"也看作是一个"数组",并且可以作为类的属性,之后会提到。

1.2 安装

项目处于建设中,未发布至NPM,请 git clone 本项目并手动 npm install <项目路径> 进行安装。

1.3 简单实例


models/apple.js

module.exports=(db)=>db.createWorm({
	name:"Apple", //声明类名
	data:{  //声明属性
		color:"text",
		ate:"int"
	},
	constructor(){ //构造器,在创建实例的时候会调用,可以不写
		this.color="red";
	},
	methods:{   //声明类的所有方法
		getColor(){
			return this.color;
		},
		isAte(){
			return this.ate == 1;
		},
		eat(){
			this.ate = 1;
		}
	}

});

models/cup.js

module.exports=(db)=>db.createWorm({
	name:"Cup",
	data:{
		water:"int",
		isdry:"int"
	},
	constructor(){
		this.water=100;
	},
	methods:{
		async drink(much){
			this.water -= much;
			if(this.water <= 0){
				this.isdry = true;
			}
		},
		isDry(){
			return this.isdry;	
		}

	}
});

models/human.js

module.exports=(db)=>db.createWorm({
	name:"Human",
	data:{
		name:"text",
		age:"int",
		apple:"Class(Apple)",
		cup:"Class(Cup)"
	},
	async constructor(name,age){
		this.name = name;
		this.age = age;
		this.apple = await db.$Apple.new();
		this.cup = await db.$Cup.new();
	},
	methods:{
		async eatAll(){
			await this.apple.eat();

			for(let i=0;i<5;i++)
				await this.cup.drink(20);
			
			let apple_ate=await this.apple.isAte();
			let cup_dry=await this.cup.isDry();

			console.log("苹果",apple_ate ? "已经被吃了" : "还没吃掉");
			console.log("水杯的水",cup_dry ? "已经喝完了" : "还没喝完");
		}
	}
})

app.js

let wormclient=require("worm.js");

async function start(){
	let db = await wormclient.create({
		host:"localhost",
		user:"root",
		password:"123456",
		database:"mysql"
	});

	await db.loadModels("./models/");


	let human = await db.$Human.new("zhy",20);


	await human.eatAll();
}

start();