mirror of
https://github.com/seejohnrun/haste-server.git
synced 2024-11-01 11:31:22 +00:00
fixed deprecation warnings
This commit is contained in:
parent
06577a4e01
commit
cd10b3dc3e
1 changed files with 8 additions and 6 deletions
|
@ -15,16 +15,18 @@ MongoDocumentStore.prototype.set = function (key, data, callback, skipExpire) {
|
||||||
if (err)
|
if (err)
|
||||||
return callback(false);
|
return callback(false);
|
||||||
|
|
||||||
db.collection('entries').update({
|
db.collection('entries').updateOne({
|
||||||
'entry_id': key,
|
'entry_id': key,
|
||||||
$or: [
|
$or: [
|
||||||
{ expiration: -1 },
|
{ expiration: -1 },
|
||||||
{ expiration: { $gt: now } }
|
{ expiration: { $gt: now } }
|
||||||
]
|
]
|
||||||
}, {
|
}, {
|
||||||
'entry_id': key,
|
$set: {
|
||||||
'value': data,
|
'entry_id': key,
|
||||||
'expiration': that.expire && !skipExpire ? that.expire + now : -1
|
'value': data,
|
||||||
|
'expiration': that.expire && !skipExpire ? that.expire + now : -1
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
upsert: true
|
upsert: true
|
||||||
}, function (err, existing) {
|
}, function (err, existing) {
|
||||||
|
@ -61,7 +63,7 @@ MongoDocumentStore.prototype.get = function (key, callback, skipExpire) {
|
||||||
callback(entry === null ? false : entry.value);
|
callback(entry === null ? false : entry.value);
|
||||||
|
|
||||||
if (entry !== null && entry.expiration !== -1 && that.expire && !skipExpire) {
|
if (entry !== null && entry.expiration !== -1 && that.expire && !skipExpire) {
|
||||||
db.collection('entries').update({
|
db.collection('entries').updateOne({
|
||||||
'entry_id': key
|
'entry_id': key
|
||||||
}, {
|
}, {
|
||||||
$set: {
|
$set: {
|
||||||
|
@ -74,7 +76,7 @@ MongoDocumentStore.prototype.get = function (key, callback, skipExpire) {
|
||||||
};
|
};
|
||||||
|
|
||||||
MongoDocumentStore.prototype.safeConnect = function (callback) {
|
MongoDocumentStore.prototype.safeConnect = function (callback) {
|
||||||
MongoClient.connect(this.connectionUrl, function (err, client) {
|
MongoClient.connect(this.connectionUrl, { useUnifiedTopology: true }, function (err, client) {
|
||||||
if (err) {
|
if (err) {
|
||||||
winston.error('error connecting to mongodb', { error: err });
|
winston.error('error connecting to mongodb', { error: err });
|
||||||
callback(err);
|
callback(err);
|
||||||
|
|
Loading…
Reference in a new issue