red-aggregate
v1.0.8
Published
**Red Aggregate** là một thư viện hỗ trợ xây dựng MongoDB Aggregation Pipeline bằng TypeScript với API kiểu fluent, giúp bạn tái sử dụng và chia sẻ các pipeline phức tạp một cách nhất quán.
Readme
Red Aggregate
Red Aggregate là một thư viện hỗ trợ xây dựng MongoDB Aggregation Pipeline bằng TypeScript với API kiểu fluent, giúp bạn tái sử dụng và chia sẻ các pipeline phức tạp một cách nhất quán.
- GitHub: LaundryShops/red-aggregation
Cài đặt
npm install red-aggregate
# hoặc
yarn add red-aggregateSử dụng cơ bản
import Aggregation, {
AggregationUpdate,
AggregationExpression,
} from 'red-aggregate';
// Ví dụ aggregation pipeline đơn giản
const agg = Aggregation.newAggregation([
Aggregation.match({ status: 'ACTIVE' }),
Aggregation.sortByCount('category'),
]);
// Hoặc dùng các helper static
const pipeline = Aggregation.newAggregation(
Aggregation.match({ status: 'ACTIVE' }),
Aggregation.sortByCount('category'),
);Aggregation Update
import { AggregationUpdate } from 'red-aggregate';
const update = AggregationUpdate
.update()
.set(
Aggregation.set().field('status').toValue('INACTIVE'),
)
.unset('deprecatedField');Scripts & Workflow
- Build TypeScript:
npm run build(output vào thư mụcdist/) - Test:
npm test(sử dụng Jest)
Tài liệu
- Toàn bộ tài liệu chi tiết được build bằng MkDocs từ thư mục
docs/. - Bạn có thể xem bản render trên GitHub Pages tại: Red Aggregation Docs
cd docs
make generate-siteSite tĩnh sau khi build sẽ nằm trong docs/generated/site.
Đóng góp
- Fork repo & tạo branch mới từ
develop. - Cài đặt dependencies:
npm install. - Viết code + test:
npm test. - Gửi Pull Request vào
develop.
License
Thư viện được phát hành dưới giấy phép ISC (xem trong package.json).
