Main | FAQ's | Features | Protocol | Examples | Download | Upgrades

MinneStoreTM Syntax Examples



Following is an example of a database of parts and assemblies for a simplified lavatory faucet. This example exhibits MinneStore's strength of managing a network of inter-related objects.

Defining the database definition:

   db := MinneStoreDB newOn: 'C:\MyDB\'.

   (db addObjectSetNamed: #Parts)
      "note: multiple classes can be stored in the same object set"
      storesClass: Part;
      indexOn: #name domain: String;
      indexOn: #number domain: Integer.

   (db addObjectSetNamed: #Assemblies)
      storesClass: Assembly;
      indexOn: #name domain: String;
      indexOn: #number domain: Integer;
      aspect: #parts holdsMany: #Parts;
      aspect: #assemblies holdsMany: #Assemblies.

   db save.

Creating and storing the objects:

   db := MinneStoreDB openOn: 'C:\MyDB\'.

   "The parts in the transaction block will all be committed or rolled back.
   (The #transaction: message will not be supported until version 2.1)"

   db transaction:
     [db store: (Part name: 'spout' number: 101).
      db store: (Part name: 'lever' number: 102).
      db store: (Part name: 'o-ring' number: 103).
      db store: (Part name: 'elbow' number: 104).
      db store: (Part name: 'gasket' number: 105).
      db store: (Part name: 'seat' number: 106).
      db store: (Part name: 'nut' number: 107).
      db store: (Part name: 'lift rod' number: 108).
      db store: (Part name: 'strap' number: 109).
      db store: (Part name: 'pivot rod' number: 110).
      db store: (Part name: 'aerator' number: 111).
      db store: (Part name: 'hub' number: 112).
     ].

   db store:
      ((Assembly name: 'Handle' number: 151)
         addPart: ((db getOne: #Parts) where: #name eq: 'lever'; execute);
         addPart: ((db getOne: #Parts) where: #name eq: 'o-ring'; execute);
         addPart: ((db getOne: #Parts) where: #name eq: 'elbow'; execute);
         addPart: ((db getOne: #Parts) where: #name eq: 'hub'; execute);
         yourself).
   db store:
      ((Assembly name: 'Drain' number: 152)
         addPart: ((db getOne: #Parts) where: #name eq: 'seat'; execute);
         addPart: ((db getOne: #Parts) where: #name eq: 'gasket'; execute);
         addPart: ((db getOne: #Parts) where: #name eq: 'o-ring'; execute);
         addPart: ((db getOne: #Parts) where: #name eq: 'nut'; execute);
         yourself).
   db store:
      ((Assembly name: 'Lift Rod' number: 153)
         addPart: ((db getOne: #Parts) where: #name eq: 'lift rod'; execute);
         addPart: ((db getOne: #Parts) where: #name eq: 'strap'; execute);
         addPart: ((db getOne: #Parts) where: #name eq: 'nut'; execute);
         addPart: ((db getOne: #Parts) where: #name eq: 'pivot rod'; execute);
         yourself).
   db store:
      ((Assembly name: 'Faucet' number: 154)
         addAssembly: ((db getOne: #Assemblies) where: #name eq: 'Drain'; execute);
         addAssembly: ((db getOne: #Assemblies) where: #name eq: 'Lift Rod'; execute);
         addAssembly: ((db getOne: #Assemblies) where: #name eq: 'Handle'; execute);
         addPart: ((db getOne: #Parts) where: #name eq: 'spout'; execute);
         addPart: ((db getOne: #Parts) where: #name eq: 'aerator'; execute);
         yourself).


Retrieving from the database:
   db := MinneStoreDB openOn: 'C:\MyDB\'.

   (db getAll: #Parts)
      where: #number between: 105 and: 110;  "inclusive"
      execute.

   (db getAll: #Parts)
      where: #name eq: #('spout' 'aerator');   "either spout or aerator"
      or: #number eq: 105;
      execute.

   (db getAll: #Assemblies)
      where: #name startsWith: 'Fa';
      execute.



Main | FAQ's | Features | Protocol | Examples | Download | Upgrades

Send suggestions, questions, etc...
Return to MinneStore main page