#!/usr/bin/gjs

const Lang = imports.lang;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const GIRepository = imports.gi.GIRepository;
const Gom = imports.gi.Gom;
const System = imports.system;

const Item = new Lang.Class({
    Name: 'Item',
    Extends: Gom.Resource,

    Properties: {
        'url': GObject.ParamSpec.string('url', 'URL',
					'A URL',
					GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE,
					''),
    },

    _init: function(props) {
        this.parent(props);

        this.id = 0;
        this.url = null;
    },
});

print (Item);
Item.set_table('items');
Item.set_primary_key('url');

// Open
let adapter = new Gom.Adapter;
adapter.open_sync('/tmp/gom-js-test.db');
let repository = new Gom.Repository({adapter: adapter});

let item = new Item();
item.url = "foo";
print (item.url);

// Migrate
let object_types = [ Item ];
repository.automatic_migrate_sync(2, object_types);

// Close
adapter.close_sync();
