0.2.0
Contains a set of simple methods to handle the redis
ReJSON
type
Returns the key
names in cache
(string)
The search string to fetch the key names
(redis.Multi?
= redis
)
The
redis
multi command object to chain(See
https://github.com/NodeRedis/node_redis#clientmulticommands
)
Promise<Array<string>>
:
The
key
names in cache
Returns the objects
cache object
(redis.Multi?
= redis
)
The
redis
multi command object to chain(See
https://github.com/NodeRedis/node_redis#clientmulticommands
)
Promise<string>
:
The
object
cache
Returns the list of objects
in cache
(redis.Multi?
= redis.multi()
)
The
redis
multi command object to chain(See
https://github.com/NodeRedis/node_redis#clientmulticommands
)
Promise<string>
:
The
objects
in cache
Sets the object
to keyName
(redis.Multi
= redis
)
The
redis
multi command object to chain(See
https://github.com/NodeRedis/node_redis#clientmulticommands
)
Promise<string>
:
The
status
of the operation
Contains a set of chewed methods to handle documents
Besides preparing GenericModel
to be happily inherited as a mongoose.Schema
super class:
Lambda
like functionality for db
connectionsmongoose-lifecycle
]https://www.npmjs.com/package/mongoose-lifecycle)(mongoose.Schema)
The
mongoose
schema object
(Function?)
The
db
connect
function
(for
Lambda
and alikes, see
https://mongoosejs.com/docs/lambda.html
)
Object
:
The
[
GenericModel
]
GenericModel
and its
[
Schema
]
https://mongoosejs.com/docs/api/schema.html#schema_Schema
// db.js
const mongoose = require('mongoose')
module.exports = () => mongoose.connect(process.env.MONGODB_URL)
// You.js
const db = require('./db')
const SCHEMA = {
name: String,
life: Number,
...
}
const OPTIONS = {
_id : true,
strict : false,
...
}
const { GenericModel, GenericSchema } = require('lib/models/GenericSchema')(SCHEMA, OPTIONS, db)
module.exports = mongoose.model('You', GenericSchema)
// file.js
const You = require('./You')
You.save({ name: 'you' })
const you = await You.getOne({ name: 'you' })
// {
// _id : idRandom,
// name: 'you'
// }
you.name = 'arpel'
await you.save()
await You.getAll()
// [(1)]
await You.find()
// [(1)]
// You.js
const { GenericModel, GenericSchema } = require('lib/models/GenericSchema')(SCHEMA, OPTIONS)
class You extends GenericModel {
arpel() {
this.name = 'arpel'
return this.save()
}
static async arpel() {
return You.save({ name: 'arpel' })
}
}
module.exports = mongoose.model('You', GenericSchema)
// file.js
const You = require('./You')
const you = new You()
await you.arpel()
await You.arpel()
You.getCount({ name: 'arpel' })
// 2
You.count({ name: 'arpel' })
// 2