2013-09-01 02:37:46 +00:00
|
|
|
// Copyright 2013 The XORM Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2013-11-22 01:20:41 +00:00
|
|
|
/*
|
2013-11-22 02:30:52 +00:00
|
|
|
Package xorm is a simple and powerful ORM for Go.
|
2013-11-22 01:20:41 +00:00
|
|
|
|
2013-11-22 02:30:52 +00:00
|
|
|
First, we should new an engine for a database
|
2013-11-22 01:20:41 +00:00
|
|
|
|
2013-11-22 02:30:52 +00:00
|
|
|
engine, err := xorm.NewEngine(driverName, dataSourceName)
|
2013-11-22 01:20:41 +00:00
|
|
|
|
|
|
|
Method NewEngine's parameters is the same as sql.Open. It depends
|
|
|
|
drivers' implementation. Generally, one engine is enough.
|
|
|
|
|
2013-11-22 02:26:01 +00:00
|
|
|
There are 7 major methods and many helpful methods to use to operate database.
|
|
|
|
|
|
|
|
1. Insert one or multipe records to database
|
|
|
|
|
|
|
|
engine.Insert(...)
|
|
|
|
|
|
|
|
2. Query one record from database
|
|
|
|
|
|
|
|
engine.Get(...)
|
|
|
|
|
|
|
|
3. Query multiple records from database
|
|
|
|
|
|
|
|
engine.Find(...)
|
|
|
|
|
|
|
|
4. Query multiple records and record by record handle
|
|
|
|
|
|
|
|
engine.Iterate(...)
|
|
|
|
|
|
|
|
5. Update one or more records
|
|
|
|
|
|
|
|
engine.Update(...)
|
|
|
|
|
|
|
|
6. Delete one or more records
|
|
|
|
|
|
|
|
engine.Delete(...)
|
|
|
|
|
|
|
|
7. Count records
|
|
|
|
|
|
|
|
engine.Count(...)
|
2013-11-22 01:20:41 +00:00
|
|
|
*/
|
2013-09-01 02:37:46 +00:00
|
|
|
package xorm
|