https://github.com/mongoosejs/mongoose-long
Provides Number Long support for Mongoose
https://github.com/mongoosejs/mongoose-long
Last synced: 2 months ago
JSON representation
Provides Number Long support for Mongoose
- Host: GitHub
- URL: https://github.com/mongoosejs/mongoose-long
- Owner: mongoosejs
- License: mit
- Created: 2012-08-01T16:43:04.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2023-11-01T02:08:47.000Z (over 1 year ago)
- Last Synced: 2025-04-02T21:18:44.808Z (3 months ago)
- Language: JavaScript
- Size: 44.9 KB
- Stars: 79
- Watchers: 3
- Forks: 16
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
README
#mongoose-long
===============Provides Number Long support for [Mongoose](http://mongoosejs.com).
[](http://travis-ci.org/mongoosejs/mongoose-long)
Example:
```js
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](https://mongodb.github.io/node-mongodb-native/4.2/classes/Long.html) docs on all the `Long` methods available.
[LICENSE](https://github.com/aheckmann/mongoose-long/blob/master/LICENSE)
### TypeScript Usage
Make sure you enable both `compilerOptions.allowSyntheticDefaultImports` and `compilerOptions.esModuleInterop` in your `tsconfig.json`.
```typescript
import mongoose from 'mongoose';
import mongooseLong from 'mongoose-long';mongooseLong(mongoose);
const Long = mongoose.Schema.Types.Long;
```