hello again, universe~ 🌸

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2025-06-30 17:41:05 -04:00
commit 486d5ee30f
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C
16 changed files with 439 additions and 0 deletions

3
.dir-locals.el Normal file
View File

@ -0,0 +1,3 @@
((nil . ((elcord-project-name . "the diamond ORM")
(elcord-project-description . "a mongodb ORM for golang that rocks!")
)))

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
*.exe
go.work.sum
go.work
muck/
/build/

8
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View File

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

View File

@ -0,0 +1,49 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="CssDeprecatedValue" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="CssInvalidAtRule" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="CssInvalidCharsetRule" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="CssInvalidCustomPropertyAtRuleDeclaration" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="CssInvalidCustomPropertyAtRuleName" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="CssInvalidFunction" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="CssInvalidHtmlTagReference" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="CssInvalidImport" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="CssInvalidMediaFeature" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="CssInvalidPropertyValue" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="CssInvalidPseudoSelector" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="CssMissingComma" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="CssNegativeValue" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="CssNoGenericFontName" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="CssNonIntegerLengthInPixels" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="CssOverwrittenProperties" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="CssRedundantUnit" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="CssReplaceWithShorthandSafely" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="CssReplaceWithShorthandUnsafely" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="CssUnknownProperty" enabled="false" level="WARNING" enabled_by_default="false">
<option name="myCustomPropertiesEnabled" value="false" />
<option name="myIgnoreVendorSpecificProperties" value="false" />
<option name="myCustomPropertiesList">
<value>
<list size="0" />
</value>
</option>
</inspection_tool>
<inspection_tool class="CssUnknownTarget" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="CssUnknownUnit" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="CssUnresolvedClassInComposesRule" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="CssUnresolvedCustomProperty" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="CssUnusedSymbol" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="GoErrorStringFormat" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="GoMixedReceiverTypes" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="GoSwitchMissingCasesForIotaConsts" enabled="true" level="WEAK WARNING" enabled_by_default="true" editorAttributes="INFO_ATTRIBUTES" />
<inspection_tool class="GoUnhandledErrorResult" enabled="true" level="WEAK WARNING" enabled_by_default="true" editorAttributes="INFO_ATTRIBUTES" />
<inspection_tool class="GrazieInspection" enabled="false" level="GRAMMAR_ERROR" enabled_by_default="false" />
<inspection_tool class="LanguageDetectionInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,7 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Default" />
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

17
.idea/material_theme_project_new.xml generated Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="migrated" value="true" />
<option name="pristineConfig" value="false" />
<option name="userId" value="1fe2f249:191aa6d861d:-7ffe" />
</MTProjectMetadataState>
</option>
<option name="titleBarState">
<MTProjectTitleBarConfigState>
<option name="overrideColor" value="false" />
</MTProjectTitleBarConfigState>
</option>
</component>
</project>

18
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="excludedPrintfFunctions.xml">
<option name="excludedDescriptors">
<set>
<PrintfFuncDescriptorState>
<option name="importPath" value="fmt" />
<option name="name" value="Errorf" />
</PrintfFuncDescriptorState>
</set>
</option>
<option name="excludedNames">
<set>
<option value="Errorf" />
</set>
</option>
</component>
</project>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/orm.iml" filepath="$PROJECT_DIR$/.idea/orm.iml" />
</modules>
</component>
</project>

9
.idea/orm.iml generated Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

12
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitSharedSettings">
<option name="FORCE_PUSH_PROHIBITED_PATTERNS">
<list />
</option>
<option name="synchronizeBranchProtectionRules" value="false" />
</component>
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"nuxt.isNuxtApp": false
}

1
document.go Normal file
View File

@ -0,0 +1 @@
package orm

15
go.mod Normal file
View File

@ -0,0 +1,15 @@
module rockfic.com/orm
go 1.24.1
require (
github.com/go-loremipsum/loremipsum v1.1.4 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.5 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/stretchr/testify v1.10.0 // indirect
golang.org/x/crypto v0.37.0 // indirect
golang.org/x/sync v0.13.0 // indirect
golang.org/x/text v0.24.0 // indirect
)

25
go.sum Normal file
View File

@ -0,0 +1,25 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-loremipsum/loremipsum v1.1.4 h1:RJaJlJwX4y9A2+CMgKIyPcjuFHFKTmaNMhxbL+sI6Vg=
github.com/go-loremipsum/loremipsum v1.1.4/go.mod h1:whNWskGoefTakPnCu2CO23v5Y7RwiG4LMOEtTDaBeOY=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.7.5 h1:JHGfMnQY+IEtGM63d+NGMjoRpysB2JBwDr5fsngwmJs=
github.com/jackc/pgx/v5 v5.7.5/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

254
testing.go Normal file
View File

@ -0,0 +1,254 @@
package orm
import (
"context"
"fmt"
"github.com/stretchr/testify/assert"
"strings"
"testing"
"time"
"github.com/go-loremipsum/loremipsum"
)
type chapter struct {
ID bson.ObjectID `json:"_id"`
Title string `json:"chapterTitle" form:"chapterTitle"`
ChapterID int `json:"chapterID" autoinc:"chapters"`
Index int `json:"index" form:"index"`
Words int `json:"words"`
Notes string `json:"notes" form:"notes"`
Genre []string `json:"genre" form:"genre"`
Bands []band `json:"bands" ref:"band,bands"`
Characters []string `json:"characters" form:"characters"`
Relationships [][]string `json:"relationships" form:"relationships"`
Adult bool `json:"adult" form:"adult"`
Summary string `json:"summary" form:"summary"`
Hidden bool `json:"hidden" form:"hidden"`
LoggedInOnly bool `json:"loggedInOnly" form:"loggedInOnly"`
Posted time.Time `json:"datePosted"`
FileName string `json:"fileName"`
Text string `json:"text" gridfs:"story_text,/stories/{{.ChapterID}}.txt"`
}
type band struct {
ID int64 `json:"_id"`
Document `json:",inline" coll:"bands"`
Name string `json:"name" form:"name"`
Locked bool `json:"locked" form:"locked"`
Characters []string `json:"characters" form:"characters"`
}
type user struct {
ID int64 `json:"_id"`
Document `json:",inline" coll:"users"`
Username string `json:"username"`
Favs []user `json:"favs" ref:"user"`
}
type story struct {
ID int64 `json:"_id"`
Document `json:",inline" coll:"stories"`
Title string `json:"title" form:"title"`
Author *user `json:"author" ref:"user"`
CoAuthor *user `json:"coAuthor" ref:"user"`
Chapters []chapter `json:"chapters"`
Recs int `json:"recs"`
Favs int `json:"favs"`
Views int `json:"views"`
Completed bool `json:"completed" form:"completed"`
Downloads int `json:"downloads"`
}
type somethingWithNestedChapters struct {
ID int64 `json:"_id"`
Document `json:",inline" coll:"nested_stuff"`
Chapters []chapter `json:"chapters"`
NestedText string `json:"text" gridfs:"nested_text,/nested/{{.ID}}.txt"`
}
func (s *somethingWithNestedChapters) Id() any {
return s.ID
}
func (s *somethingWithNestedChapters) SetId(id any) {
s.ID = id.(int64)
}
func (s *story) Id() any {
return s.ID
}
func (s *band) Id() any {
return s.ID
}
func (s *user) Id() any {
return s.ID
}
func (s *story) SetId(id any) {
s.ID = id.(int64)
//var t IDocument =s
}
func (s *band) SetId(id any) {
s.ID = id.(int64)
}
func (s *user) SetId(id any) {
s.ID = id.(int64)
}
var author = user{
Username: "tablet.exe",
Favs: []user{
{
Username: "DarQuiel7",
},
},
}
func genChaps(single bool) []chapter {
var ret []chapter
var ceil int
if single {
ceil = 1
} else {
ceil = 5
}
emptyRel := make([][]string, 0)
emptyRel = append(emptyRel, make([]string, 0))
relMap := [][][]string{
{
{"Sean Harris", "Brian Tatler"},
},
{
{"Sean Harris", "Brian Tatler"},
{"Duncan Scott", "Colin Kimberley"},
},
{
{"Duncan Scott", "Colin Kimberley"},
},
emptyRel,
{
{"Sean Harris", "Colin Kimberley", "Brian Tatler"},
},
}
l := loremipsum.New()
for i := 0; i < ceil; i++ {
spf := fmt.Sprintf("%d.md", i+1)
ret = append(ret, chapter{
ID: bson.NewObjectID(),
Title: fmt.Sprintf("-%d-", i+1),
Index: i + 1,
Words: 50,
Notes: "notenotenote !!!",
Genre: []string{"Slash"},
Bands: []band{diamondHead},
Characters: []string{"Sean Harris", "Brian Tatler", "Duncan Scott", "Colin Kimberley"},
Relationships: relMap[i],
Adult: true,
Summary: l.Paragraph(),
Hidden: false,
LoggedInOnly: true,
FileName: spf,
Text: strings.Join(l.ParagraphList(10), "\n\n"),
})
}
return ret
}
func doSomethingWithNested() somethingWithNestedChapters {
l := loremipsum.New()
swnc := somethingWithNestedChapters{
Chapters: genChaps(false),
NestedText: strings.Join(l.ParagraphList(15), "\n\n"),
}
return swnc
}
func iti_single() story {
return story{
Title: "title",
Completed: true,
Chapters: genChaps(true),
}
}
func iti_multi() story {
return story{
Title: "Brian Tatler Fucked and Abused Sean Harris",
Completed: false,
Chapters: genChaps(false),
}
}
func iti_blank() story {
t := iti_single()
t.Chapters = make([]chapter, 0)
return t
}
func initTest() {
uri := "mongodb://127.0.0.1:27017"
db := "rockfic_ormTest"
ic, _ := mongo.Connect(options.Client().ApplyURI(uri))
ic.Database(db).Drop(context.TODO())
colls, _ := ic.Database(db).ListCollectionNames(context.TODO(), bson.M{})
if len(colls) < 1 {
mdb := ic.Database(db)
mdb.CreateCollection(context.TODO(), "bands")
mdb.CreateCollection(context.TODO(), "stories")
mdb.CreateCollection(context.TODO(), "users")
}
defer ic.Disconnect(context.TODO())
Connect(uri, db)
author.ID = 696969
ModelRegistry.Model(band{}, user{}, story{})
}
var metallica = band{
ID: 1,
Name: "Metallica",
Characters: []string{
"James Hetfield",
"Lars Ulrich",
"Kirk Hammett",
"Cliff Burton",
},
Locked: false,
}
var diamondHead = band{
ID: 503,
Name: "Diamond Head",
Locked: false,
Characters: []string{
"Brian Tatler",
"Sean Harris",
"Duncan Scott",
"Colin Kimberley",
},
}
var bodom = band{
ID: 74,
Name: "Children of Bodom",
Locked: false,
Characters: []string{
"Janne Wirman",
"Alexi Laiho",
"Jaska Raatikainen",
"Henkka T. Blacksmith",
"Roope Latvala",
"Daniel Freyberg",
"Alexander Kuoppala",
},
}
func saveDoc(t *testing.T, doc IDocument) {
err := doc.Save()
assert.Nil(t, err)
}
func createAndSave(t *testing.T, doc IDocument) {
mdl := Create(doc).(IDocument)
saveDoc(t, mdl)
}