const modelUtils = require('./utils')
const peertubeCrypto = require('../helpers/peertube-crypto')
+const OAuthToken = mongoose.model('OAuthToken')
+
// ---------------------------------------------------------------------------
const UserSchema = mongoose.Schema({
UserSchema.statics = {
countTotal: countTotal,
getByUsername: getByUsername,
+ list: list,
listForApi: listForApi,
loadById: loadById,
loadByUsername: loadByUsername
})
})
+UserSchema.pre('remove', function (next) {
+ const user = this
+
+ OAuthToken.removeByUserId(user._id, next)
+})
+
mongoose.model('User', UserSchema)
// ------------------------------ METHODS ------------------------------
return this.findOne({ username: username })
}
+function list (callback) {
+ return this.find(callback)
+}
+
function listForApi (start, count, sort, callback) {
const query = {}
return modelUtils.listForApiWithCount.call(this, query, start, count, sort, callback)