mongoose-long

Long number type for Mongoose

MIT 17 个版本
安装
npm install mongoose-long
yarn add mongoose-long
pnpm add mongoose-long
bun add mongoose-long
README

#mongoose-long

Provides Number Long support for Mongoose.

Build Status

Example:

const mongoose = require('mongoose')
require('mongoose-long')(mongoose);
const {Types: {Long}} = mongoose;

const partSchema = new Schema({
  long: {
    type: Long,
  }
});

const Part = db.model('Part', partSchema);
const part = new Part({long: '9223372036854775806'});

part.long = part.long.divide(Long.fromString('2'));
part.save()

install

npm install mongoose-long

See node-mongodb-native docs on all the Long methods available.

LICENSE

TypeScript Usage

Make sure you enable both compilerOptions.allowSyntheticDefaultImports and compilerOptions.esModuleInterop in your tsconfig.json.

import mongoose from 'mongoose';
import mongooseLong from 'mongoose-long';

mongooseLong(mongoose);

const Long = mongoose.Schema.Types.Long;
版本列表
0.8.0 2023-11-01
0.7.1 2023-08-22
0.7.0 2023-06-01
0.6.0 2022-10-25
0.5.1 2022-01-05
0.5.0 2021-10-21
0.4.1 2021-08-10
0.4.0 2021-05-21
0.3.2 2020-09-19
0.3.1 2020-07-18
0.3.0 2020-04-18
0.2.1 2018-05-17
0.2.0 2018-02-26
0.1.1 2016-10-17
0.1.0 2016-01-28
0.0.2 2012-10-18
0.0.1 2012-08-01