github.com/dgraph-io/dgraph@v1.2.8/types/facets/facet_types.go (about) 1 /* 2 * Copyright 2017-2018 Dgraph Labs, Inc. and Contributors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package facets 18 19 import "github.com/dgraph-io/dgo/v2/protos/api" 20 21 const ( 22 // IntID represents the integer type. 23 IntID = TypeID(api.Facet_INT) 24 // FloatID represents the floating-point number type. 25 FloatID = TypeID(api.Facet_FLOAT) 26 // BoolID represents the boolean type. 27 BoolID = TypeID(api.Facet_BOOL) 28 // DateTimeID represents the datetime type. 29 DateTimeID = TypeID(api.Facet_DATETIME) 30 // StringID represents the string type. 31 StringID = TypeID(api.Facet_STRING) 32 ) 33 34 // TypeID represents the type of a facet. 35 type TypeID api.Facet_ValType 36 37 // ValTypeForTypeID gives api.Facet_ValType for given TypeID 38 func ValTypeForTypeID(typId TypeID) api.Facet_ValType { 39 switch typId { 40 case IntID: 41 return api.Facet_INT 42 case FloatID: 43 return api.Facet_FLOAT 44 case BoolID: 45 return api.Facet_BOOL 46 case DateTimeID: 47 return api.Facet_DATETIME 48 case StringID: 49 return api.Facet_STRING 50 } 51 panic("Unhandled case in ValTypeForTypeID.") 52 }