Comments (2)
@naxiaoguang 时间太久了,不好意思,一直没有时间
今天测试了下
环境
- run-rs 4.2.0
- Windows10
- Node 12.14.0
代码
const mongoose = require('mongoose')
const Acid = require('mongoose-acid')
const os = require('os')
const hostname = os.hostname()
mongoose.set('debug', false)
Acid.set('debug', false)
const uri = os.platform() === 'win32' ? `mongodb://${hostname}:27017,${hostname}:27018,${hostname}:27019/test` : 'mongodb://localhost:27017,localhost:27018,localhost:27019/test'
let conn
const Account = mongoose.model('Account', new mongoose.Schema({
balance: Number
}))
const People = mongoose.model('People', new mongoose.Schema({
name: String,
balance: Number
}))
async function test() {
let conn = await mongoose.connect(uri, {
replicaSet: 'rs',
useUnifiedTopology: true,
useNewUrlParser: true
})
// await new Account({ balance: 300 }).save()
await Acid(async (session) => {
let account = await Account.findOne({ _id: '5e1438aef13bc455b07bf22d' }).session(session)
account.balance += 300
await account.save()
await new People({ balance: account.balance }).save({ session })
throw new Error('THROW ERROR')
})
await conn.disconnect()
}
test()
并没有发现你出现的问题,你的问题应该和这个库没有关系,应该是你mongodb连接的配置问题?
from mongoose-acid.
from mongoose-acid.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongoose-acid.