good morning!!!!

Skip to content
Snippets Groups Projects
Commit d31727a3 authored by José Carlos Nieto's avatar José Carlos Nieto
Browse files

Forgot to change Where to Cond in docs.

parent 1aefda90
No related branches found
No related tags found
No related merge requests found
...@@ -134,7 +134,7 @@ Appends one or more items to the collection. ...@@ -134,7 +134,7 @@ Appends one or more items to the collection.
Returns the number of total items matching the provided conditions. Returns the number of total items matching the provided conditions.
total := collection.Count(Where { "name": "Peter" }) total := collection.Count(Cond { "name": "Peter" })
#### db.Collection.Find(...interface{}) db.Item #### db.Collection.Find(...interface{}) db.Item
...@@ -142,11 +142,11 @@ Return the first Item of the collection that matches all the provided conditions ...@@ -142,11 +142,11 @@ Return the first Item of the collection that matches all the provided conditions
// The following statement is equivalent to WHERE name = "John" AND last_name = "Doe" AND (age = 15 OR age = 20) // The following statement is equivalent to WHERE name = "John" AND last_name = "Doe" AND (age = 15 OR age = 20)
collection.Find( collection.Find(
db.Where { "name": "John" }, db.Cond { "name": "John" },
db.Where { "last_name": "Doe" }, db.Cond { "last_name": "Doe" },
db.Or { db.Or {
db.Where { "age": 15 }, db.Cond { "age": 15 },
db.Where { "age": 20 }, db.Cond { "age": 20 },
}, },
) )
...@@ -158,7 +158,7 @@ You can also use relations in your definition ...@@ -158,7 +158,7 @@ You can also use relations in your definition
"lives_in": db.On{ "lives_in": db.On{
session.Collection("places"), session.Collection("places"),
// Relates rows of the table "places" where place.code_id = collection.place_code_id. // Relates rows of the table "places" where place.code_id = collection.place_code_id.
db.Where{"code_id": "{place_code_id}"}, db.Cond{"code_id": "{place_code_id}"},
}, },
}, },
db.RelateAll{ db.RelateAll{
...@@ -166,20 +166,20 @@ You can also use relations in your definition ...@@ -166,20 +166,20 @@ You can also use relations in your definition
"has_children": On{ "has_children": On{
session.Collection("children"), session.Collection("children"),
// Relates rows of the table "children" where children.parent_id = collection.id // Relates rows of the table "children" where children.parent_id = collection.id
db.Where{"parent_id": "{id}"}, db.Cond{"parent_id": "{id}"},
}, },
// One-to-many relation with the table "visits". // One-to-many relation with the table "visits".
"has_visited": db.On{ "has_visited": db.On{
session.Collection("visits"), session.Collection("visits"),
// Relates rows of the table "visits" where visits.person_id = collection.id // Relates rows of the table "visits" where visits.person_id = collection.id
db.Where{"person_id": "{id}"}, db.Cond{"person_id": "{id}"},
// A nested relation // A nested relation
db.Relate{ db.Relate{
// Relates rows of the table "places" with the "visits" table. // Relates rows of the table "places" with the "visits" table.
"place": db.On{ "place": db.On{
session.Collection("places"), session.Collection("places"),
// Where places.id = visits.place_id // Cond places.id = visits.place_id
db.Where{"id": "{place_id}"}, db.Cond{"id": "{place_id}"},
}, },
}, },
}, },
...@@ -194,7 +194,7 @@ Be aware that there are some extra parameters that you can pass to ``db.Collecti ...@@ -194,7 +194,7 @@ Be aware that there are some extra parameters that you can pass to ``db.Collecti
// Just give me the the first 10 rows with last_name = "Smith" // Just give me the the first 10 rows with last_name = "Smith"
collection.Find( collection.Find(
db.Where { "last_name": "Smith" }, db.Cond { "last_name": "Smith" },
db.Limit(10), db.Limit(10),
) )
...@@ -204,19 +204,19 @@ Updates all the items of the collection that match all the provided conditions. ...@@ -204,19 +204,19 @@ Updates all the items of the collection that match all the provided conditions.
// Example of assigning field values with Set: // Example of assigning field values with Set:
collection.Update( collection.Update(
db.Where { "name": "José" }, db.Cond { "name": "José" },
db.Set { "name": "Joseph"}, db.Set { "name": "Joseph"},
) )
// Example of custom modification with db.Modify (for mongo.Session): // Example of custom modification with db.Modify (for mongo.Session):
collection.Update( collection.Update(
db.Where { "times <": "10" }, db.Cond { "times <": "10" },
db.Modify { "$inc": { "times": 1 } }, db.Modify { "$inc": { "times": 1 } },
) )
// Example of inserting if none matches with db.Upsert (for mongo.Session): // Example of inserting if none matches with db.Upsert (for mongo.Session):
collection.Update( collection.Update(
db.Where { "name": "Roberto" }, db.Cond { "name": "Roberto" },
db.Upsert { "name": "Robert"}, db.Upsert { "name": "Robert"},
) )
...@@ -225,8 +225,8 @@ Updates all the items of the collection that match all the provided conditions. ...@@ -225,8 +225,8 @@ Updates all the items of the collection that match all the provided conditions.
Deletes all the items of the collection that match the provided conditions. Deletes all the items of the collection that match the provided conditions.
collection.Remove( collection.Remove(
db.Where { "name": "Peter" }, db.Cond { "name": "Peter" },
db.Where { "last_name": "Parker" }, db.Cond { "last_name": "Parker" },
) )
#### db.Collection.Truncate() bool #### db.Collection.Truncate() bool
...@@ -253,6 +253,6 @@ Or you can [browse it](http://go.pkgdoc.org/github.com/xiam/gosexy/db) online. ...@@ -253,6 +253,6 @@ Or you can [browse it](http://go.pkgdoc.org/github.com/xiam/gosexy/db) online.
## Changelog ## Changelog
2012/07/23 - Splitted databases wrapper into packages. Changed ``Where`` to ``Cond``. 2012/07/23 - Splitted databases wrapper into packages. Changed ``Cond`` to ``Cond``.
2012/07/09 - First public beta with MySQL, MongoDB, PostgreSQL and SQLite3. 2012/07/09 - First public beta with MySQL, MongoDB, PostgreSQL and SQLite3.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment