Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
egg-nohm
Advanced tools
Readme
$ npm i egg-nohm --save
nohm 详细请看https://github.com/maritz/nohm
// 模型定义,app/nohm/model目录下的文件会自动加载
// app/nohm/model/ObjModel.js
const nohm = require('nohm').Nohm;
// 别忘记了module.exports =.
module.exports = nohm.model('ObjectModel', {
properties: {
nickName: {
type: 'string',
},
currentSong: {
type: 'json',
},
currentListType: {
type: 'string',
defaultValue: 'local',
},
localList: {
type: 'json',
defaultValue: { items: [] },
},
playList: {
type: 'json',
defaultValue: { items: [] },
},
},
});
//也可以
// app/nohm/model/PlayingSong.js
const nohm = require('nohm').Nohm;
module.exports = app => {
const PlayingSong = nohm.model('PlayingSong', {
properties: {
nickName: {
type: 'string',
},
currentSong: {
type: 'json',
},
currentListType: {
type: 'string',
defaultValue: 'local',
},
localList: {
type: 'json',
defaultValue: { items: [] },
},
playList: {
type: 'json',
defaultValue: { items: [] },
},
},
});
return PlayingSong;
};
// 所有app/nohm/model下的文件会加载到app.nohmModel
const PlayingSong = app.nohmModel.PlayingSong;
const ps = new PlayingSong();
ps.id = 'abc';
const nickName = 'who am i ';
ps.p({
nickName,
});
yield ps.save$();
const data = yield PlayingSong.load$(ps.id);
assert(data.nickName === nickName);
yield PlayingSong.remove$(ps.id);
// {app_root}/config/plugin.js
exports.redis = {
enable: true,
package: 'egg-redis',
};
exports.nohm = {
enable: true,
package: 'egg-nohm',
};
nohm中的方法以$结尾的都promisify了. 如原方法save, 会另外增加一个save$返回promise
// {app_root}/config/config.default.js
exports.redis = {
client: {
host: '127.0.0.1',
port: 6379,
password: '',
db: '0',
},
};
exports.nohm = {
};
如果你期望下面的代码
var model=new SomeNohmModel()
model.id='abcd'
model.save()
不管这里的id存在还是不存在,都以这个id保存到redis中. 如果存在id='abcd'的,就更新. 如果不存在新插入对象的id还是等于'abcd'.请加下面的配置.
idGenerator (cb) {
cb(this.id)
}
因为nohm默认的行为是
see config/config.default.js for more detail.
Please open an issue here.
FAQs
[![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][codecov-image]][codecov-url] [![David deps][david-image]][david-url] [![Known Vulnerabilities][snyk-image]][snyk-url] [![npm download][download-image]][down
The npm package egg-nohm receives a total of 2 weekly downloads. As such, egg-nohm popularity was classified as not popular.
We found that egg-nohm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.