Search code examples
google-app-enginegroovygoogle-cloud-datastoregaelyk

In GAELYK, how do i store the form-submitted params variable as Text type in entity/datastore


Im using Gaelyk to build an app on Google app engine, I have a form that submits contents of a text-area (which exceeds 500 characters), to be saved in datastore.

so here is what i did :-

//add-a-book.groovy
import com.google.appengine.api.datastore.Entity

def book = new Entity("Book")
book.title = params.title
book.story = params.description
book.save()

So, this code does not work as book.story is being considered as String and hence the 500 chars limit on it,

now how do i define it as a datatype of Text.. i understand its a beginners question, can anybody pls help ?


Solution

  • You should just be able to do

    book.story = params.description as Text
    

    The converters are described in the second yellow box (at time of posting) on the tutorial page