@armi-wave/common 1.22.0 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/models/Follow.d.ts +24 -0
- package/build/models/Follow.js +36 -0
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
interface FollowAttributes {
|
|
3
|
+
userId: string;
|
|
4
|
+
followers: Record<string, {
|
|
5
|
+
followedAt: Date;
|
|
6
|
+
}>;
|
|
7
|
+
following: Record<string, {
|
|
8
|
+
followedAt: Date;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
interface FollowModel extends mongoose.Model<FollowDocument> {
|
|
12
|
+
build(attrs: FollowAttributes): FollowDocument;
|
|
13
|
+
}
|
|
14
|
+
interface FollowDocument extends mongoose.Document {
|
|
15
|
+
userId: string;
|
|
16
|
+
followers: Record<string, {
|
|
17
|
+
followedAt: Date;
|
|
18
|
+
}>;
|
|
19
|
+
following: Record<string, {
|
|
20
|
+
followedAt: Date;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
declare const Follow: FollowModel;
|
|
24
|
+
export default Follow;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
7
|
+
const followSchema = new mongoose_1.default.Schema({
|
|
8
|
+
userId: { type: String, required: true },
|
|
9
|
+
followers: {
|
|
10
|
+
type: Map,
|
|
11
|
+
of: {
|
|
12
|
+
followedAt: { type: Date, required: true },
|
|
13
|
+
},
|
|
14
|
+
default: {},
|
|
15
|
+
},
|
|
16
|
+
following: {
|
|
17
|
+
type: Map,
|
|
18
|
+
of: {
|
|
19
|
+
followedAt: { type: Date, required: true },
|
|
20
|
+
},
|
|
21
|
+
default: {},
|
|
22
|
+
},
|
|
23
|
+
}, {
|
|
24
|
+
toJSON: {
|
|
25
|
+
transform(doc, ret) {
|
|
26
|
+
ret.id = ret._id;
|
|
27
|
+
delete ret.__v;
|
|
28
|
+
delete ret._id;
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
followSchema.statics.build = (attrs) => {
|
|
33
|
+
return new Follow(attrs);
|
|
34
|
+
};
|
|
35
|
+
const Follow = mongoose_1.default.model('Follow', followSchema);
|
|
36
|
+
exports.default = Follow;
|