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

indexdb-storage-js

v1.0.4

Published

A storage solution for chat applications using Dexie.js

Downloads

206

Readme

# indexdb-storage-js

indexdb-storage-js是一个基于 Dexie.js 的前端存储解决方案,专为聊天应用设计。它提供了用于管理消息、好友列表、聊天列表、朋友圈数据以及媒体文件的接口。

## 安装

```bash
npm install indexdb-storage-js

使用方法

初始化

在你的项目中引入并初始化:

import {
  addMessage,
  getMessagesByChat,
  addFriend,
  getFriendList,
  addOrUpdateChatList,
  getChatList,
  addPost,
  getSocialFeed,
  addMediaFile,
  getMediaFiles
} from 'indexdb-storage-js';

消息管理

添加消息

const message = {
  sender: 'Alice',
  receiver: 'Bob',
  content: 'Hello, Bob!',
  timestamp: new Date().toISOString()
};

addMessage(userId,message).then(() => {
  console.log('Message added successfully!');
});

获取特定聊天的消息

getMessagesByChat(userId,'Alice', 'Bob').then(messages => {
  console.log('Chat messages:', messages);
});

好友管理

添加好友

const friend = {
  name: 'Charlie',
  status: 'online',
  lastActive: new Date().toISOString()
};

addFriend(userId,friend).then(() => {
  console.log('Friend added successfully!');
});

获取好友列表

getFriendList(userId).then(friends => {
  console.log('Friend list:', friends);
});

聊天列表管理

添加或更新聊天条目

const chat = {
  userId: 'Bob',
  lastMessage: 'Hello!',
  timestamp: new Date().toISOString()
};

addOrUpdateChatList(userId,chat).then(() => {
  console.log('Chat list updated successfully!');
});

获取聊天列表

getChatList(userId).then(chats => {
  console.log('Chat list:', chats);
});

朋友圈管理

添加朋友圈动态

const post = {
  userId: 'Alice',
  content: 'Having a great day!',
  media: null,  // 可以是图片或视频的路径
  timestamp: new Date().toISOString()
};

addPost(userId,post).then(() => {
  console.log('Post added successfully!');
});

获取朋友圈动态

getSocialFeed(userId).then(posts => {
  console.log('Social feed:', posts);
});

媒体文件管理

添加媒体文件

const file = {
  type: 'image',
  path: '/path/to/image.jpg',
  timestamp: new Date().toISOString()
};

addMediaFile(userId,file).then(() => {
  console.log('Media file added successfully!');
});

获取所有媒体文件

getMediaFiles(userId).then(files => {
  console.log('Media files:', files);
});

贡献

欢迎任何形式的贡献!请确保在提交 PR 之前遵循项目的代码风格和测试标准。

许可证

MIT License