indexing

package
v0.0.0-...-048a247 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DatabaseRefAPI = []collectionRef{

	{
		Name: string(mongo.CollectionNameUsers),
		Indexes: []mongo.IndexModel{
			{Keys: bson.M{"username": 1}, Options: options.Index().SetUnique(true)},
			{Keys: bson.M{"connections.id": 1}},
			{Keys: bson.M{"connections.data.login": 1}},
			{Keys: bson.M{"connections.emote_set_id": 1}},
			{Keys: bson.M{"state.role_position": -1}},
			{Keys: bson.M{"editors.id": -1}},
		},
		Validator: &jsonSchema{
			BSONType: TList{BSONTypeObject},
			Title:    "Users",
			Required: []string{"username", "discriminator"},
			Properties: map[string]*jsonSchema{
				"type": {BSONType: TList{BSONTypeString}, Enum: []string{"", "BOT", "SYSTEM"}},
				"username": {
					BSONType:  TList{BSONTypeString},
					MinLength: utils.PointerOf(int64(1)),
					MaxLength: utils.PointerOf(int64(25)),
				},
				"dislay_name":   {BSONType: TList{BSONTypeString}},
				"discriminator": {BSONType: TList{BSONTypeString}, MinLength: utils.PointerOf(int64(4)), MaxLength: utils.PointerOf(int64(4))},
				"email":         {BSONType: TList{BSONTypeString}},
				"role_ids": {
					BSONType: TList{BSONTypeArray},
					Items:    []*jsonSchema{{BSONType: TList{BSONTypeObjectId}}},
				},
				"editors": {
					BSONType: TList{BSONTypeArray},
					Items: []*jsonSchema{{
						BSONType: TList{BSONTypeObject},
						Required: []string{"id", "permissions"},
						Properties: map[string]*jsonSchema{
							"id":          {BSONType: TList{BSONTypeObjectId}},
							"connections": {BSONType: TList{BSONTypeArray}, Items: []*jsonSchema{{BSONType: TList{BSONTypeObjectId}}}},
							"permissions": {BSONType: TList{BSONTypeInt32}},
							"visible":     {BSONType: TList{BSONTypeBoolean}},
							"added_at":    {BSONType: TList{BSONTypeDate}},
						},
					}},
				},
				"avatar_id":     {BSONType: TList{BSONTypeString}},
				"biography":     {BSONType: TList{BSONTypeString}},
				"token_version": {BSONType: TList{BSONTypeDouble}},
				"connections": {
					BSONType: TList{BSONTypeArray},
					Items: []*jsonSchema{{
						BSONType: TList{BSONTypeObject},
						Properties: map[string]*jsonSchema{
							"id":        {BSONType: TList{BSONTypeString}},
							"platform":  {BSONType: TList{BSONTypeString}, Enum: []string{"TWITCH", "YOUTUBE", "DISCORD", "KICK"}},
							"linked_at": {BSONType: TList{BSONTypeDate}},
						},
					}},
				},
			},
		},
	},

	{
		Name: string(mongo.CollectionNameUserPresences),
		Indexes: []mongo.IndexModel{
			{Keys: bson.M{"actor_id": -1}},
			{Keys: bson.M{"ip": -1}},
			{Keys: bson.M{"ttl": -1}, Options: options.Index().SetExpireAfterSeconds(0)},
			{
				Keys:    bson.M{"data.id": -1},
				Options: options.Index().SetPartialFilterExpression(bson.M{"kind": structures.UserPresenceKindChannel}),
			},
		},
	},

	{
		Name: "emotes",
		Indexes: []mongo.IndexModel{
			{Keys: bson.M{"owner_id": -1}},
			{
				Keys: bson.D{{Key: "versions.id", Value: -1}},
			},
			{Keys: bson.D{
				{Key: "name", Value: "text"},
			}, Options: options.Index().SetTextVersion(3)},
			{Keys: bson.M{"tags": 1}},
			{Keys: bson.M{"versions.state.channel_count": -1}},
			{
				Keys: bson.M{"versions.state.listed": 1},
				Options: options.Index().SetName("listed").SetPartialFilterExpression(bson.M{
					"versions.state.listed": true,
				}),
			},

			{
				Keys: bson.M{"versions.state.lifecycle": -1},
				Options: options.Index().SetName("lifecycle_live").SetPartialFilterExpression(bson.M{
					"versions.state.lifecycle": structures.EmoteLifecycleLive,
				}),
			},
		},
		Validator: &jsonSchema{
			BSONType: TList{BSONTypeObject},
			Title:    "Emotes",
			Required: []string{"name", "versions"},
			Properties: map[string]*jsonSchema{
				"owner_id": {BSONType: TList{BSONTypeObjectId}},
				"name":     {BSONType: TList{BSONTypeString}, MinLength: utils.PointerOf(int64(1))},
				"flags":    {BSONType: TList{BSONTypeInt32, BSONTypeInt64}},
				"tags":     {BSONType: TList{BSONTypeArray}},
				"versions": {
					BSONType: TList{BSONTypeArray},
					Items: []*jsonSchema{{
						BSONType: TList{BSONTypeObject},
						Required: []string{"id", "state"},
						Properties: map[string]*jsonSchema{
							"name": {BSONType: TList{BSONTypeString}},
							"state": {
								BSONType: TList{BSONTypeObject},
								Properties: map[string]*jsonSchema{
									"lifecycle": {
										BSONType: TList{BSONTypeInt32},
										Minimum:  utils.PointerOf(int64(-2)),
										Maximum:  utils.PointerOf(int64(3)),
									},
								},
							},
						},
					}},
				},
				"parent_id":    {BSONType: TList{BSONTypeObjectId, BSONTypeNull}},
				"children_ids": {BSONType: TList{BSONTypeArray}, Items: []*jsonSchema{{BSONType: TList{BSONTypeObjectId}}}},
			},
		},
	},

	{
		Name: string(mongo.CollectionNameEntitlements),
		Indexes: []mongo.IndexModel{
			{Keys: bson.M{"data.ref": -1}},
			{Keys: bson.M{"user_id": 1}},
		},
	},

	{
		Name: string(mongo.CollectionNameEmoteSets),
		Indexes: []mongo.IndexModel{
			{Keys: bson.M{"emotes.id": -1}},
			{Keys: bson.M{"emotes.name": -1}},
			{Keys: bson.M{"owner_id": -1}},
			{Keys: bson.M{"origins.id": -1}},
		},
	},

	{
		Name: string(mongo.CollectionNameRoles),
		Indexes: []mongo.IndexModel{
			{Keys: bson.M{"position": 1}},
		},
	},

	{
		Name: string(mongo.CollectionNameMessagesRead),
		Indexes: []mongo.IndexModel{
			{Keys: bson.M{"message_id": -1}},
			{Keys: bson.M{"recipient_id": -1}},
		},
	},

	{
		Name: string(mongo.CollectionNameMessages),
		Indexes: []mongo.IndexModel{
			{
				Keys: bson.M{"data.target_id": -1},
				Options: options.Index().SetPartialFilterExpression(bson.M{
					"kind": structures.MessageKindModRequest,
				}),
			},
		},
	},

	{
		Name: string(mongo.CollectionNameAuditLogs),
		Indexes: []mongo.IndexModel{
			{Keys: bson.M{"target_id": -1}},
			{Keys: bson.M{"actor_id": -1}},
		},
	},
}

Functions

func CollSync

func CollSync(inst mongo.Instance, colls []collectionRef) error

Types

type BSONType

type BSONType string
const (
	BSONTypeDouble     BSONType = "double"
	BSONTypeString     BSONType = "string"
	BSONTypeObject     BSONType = "object"
	BSONTypeArray      BSONType = "array"
	BSONTypeBinary     BSONType = "binData"
	BSONTypeObjectId   BSONType = "objectId"
	BSONTypeBoolean    BSONType = "bool"
	BSONTypeDate       BSONType = "date"
	BSONTypeNull       BSONType = "null"
	BSONTypeRegular    BSONType = "regex"
	BSONTypeJavaScript BSONType = "javascript"
	BSONTypeInt32      BSONType = "int"
	BSONTypeTimestamp  BSONType = "timestamp"
	BSONTypeInt64      BSONType = "long"
	BSONTypeDecimal128 BSONType = "decimal"
	BSONTypeMinkey     BSONType = "minKey"
	BSONTypeMaxkey     BSONType = "maxKey"
)

type IndexRef

type IndexRef struct {
	Collection mongo.CollectionName
	Index      mongo.IndexModel
}

type TList

type TList []BSONType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL