github.com/wangyougui/gf/v2@v2.6.5/database/gdb/gdb_schema.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/wangyougui/gf. 6 7 package gdb 8 9 // Schema is a schema object from which it can then create a Model. 10 type Schema struct { 11 DB 12 } 13 14 // Schema creates and returns a schema. 15 func (c *Core) Schema(schema string) *Schema { 16 // Do not change the schema of the original db, 17 // it here creates a new db and changes its schema. 18 db, err := NewByGroup(c.GetGroup()) 19 if err != nil { 20 panic(err) 21 } 22 core := db.GetCore() 23 // Different schema share some same objects. 24 core.logger = c.logger 25 core.cache = c.cache 26 core.schema = schema 27 return &Schema{ 28 DB: db, 29 } 30 }