good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
upper
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
open
upper
Commits
1f580b50
Commit
1f580b50
authored
11 years ago
by
Carlos Nieto
Browse files
Options
Downloads
Patches
Plain Diff
Using UpsertId.
parent
8a243f9f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
db.go
+2
-2
2 additions, 2 deletions
db.go
mongo/collection.go
+5
-3
5 additions, 3 deletions
mongo/collection.go
with
7 additions
and
5 deletions
db.go
+
2
−
2
View file @
1f580b50
...
...
@@ -22,8 +22,8 @@
*/
/*
Th
a
main goal of the upper.io/db
is simple: to save Go maps or structs to a
permanent storage engine and th
en st
ay out of the way
.
Th
e
main goal of the upper.io/db
package is to provide a simple way to save
and retrive Go structs to and from permant
en
t
st
orage
.
*/
package
db
...
...
This diff is collapsed.
Click to expand it.
mongo/collection.go
+
5
−
3
View file @
1f580b50
...
...
@@ -91,9 +91,11 @@ func compileStatement(where db.Cond) bson.M {
default
:
op
=
chunks
[
1
]
}
conds
[
chunks
[
0
]]
=
bson
.
M
{
op
:
toInternal
(
val
)}
//conds[chunks[0]] = bson.M{op: toInternal(val)}
conds
[
chunks
[
0
]]
=
bson
.
M
{
op
:
val
}
}
else
{
conds
[
key
]
=
toInternal
(
val
)
//conds[key] = toInternal(val)
conds
[
key
]
=
val
}
}
...
...
@@ -183,7 +185,7 @@ func (self *Collection) Append(item interface{}) (interface{}, error) {
var
id
bson
.
ObjectId
// Dirty trick to return the Id with ease.
res
,
err
:=
self
.
collection
.
Upsert
(
bson
.
M
{
"_id"
:
nil
}
,
toInternal
(
item
)
)
res
,
err
:=
self
.
collection
.
Upsert
Id
(
nil
,
item
)
if
err
!=
nil
{
return
nil
,
err
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment