Sorry, I'm stuck with libByName.find(query)

619 views
Skip to first unread message

Pedro Mapo

unread,
Jan 9, 2017, 11:26:28 AM1/9/17
to mementodatabase
Can anyone give me a practical example of the method find(query)?
libByName (the name of the Libary).find (query)?
I would need examples of the syntax of using this "query".

var a = libByName("A");
var q = a.find("field1" == d && "field2 == "sample");

This is not a valid query, but How is a correct query?
Thanks in advance.

Bill Crews

unread,
Jan 9, 2017, 12:19:59 PM1/9/17
to mementodatabase
If you continue to have trouble, press post again with specific issues. In the meantime, here's what the wiki says about it (Entries List screen page)...

Search icon

Pressing the magnifying-glass Search icon in the upper-right portion of the screen opens a text box at the top of the screen for entry of a search key. A list of recently-used search keys is displayed, allowing the user to readily repeat a recent search.

As the user types the search key, the list of recent search keys is replaced by a list of matching entry identifiers (concatenated Name fields) with the library. If one of them is selected, the entry is opened in an Entry View card.

If Enter is pressed instead, the search is executed based on the key value entered, and all entries containing a match in any searchable field are listed.

Search is supported not only for unencrypted libraries, but also for encrypted libraries.

Advanced search keys

You can use the asterisk (*) to substitute for any number of characters in a row on the tail end of a keyword.

For example, if you search for gloss*, all entries containing words beginning with gloss will be found.

The query syntax supports the OR binary set operator. The operator must be entered using capital letters.

For example, if you search for sqlite OR database, all entries containing words sqlite or database will be found.

The query syntax supports a unary "-" operator that may be applied to basic term and term-prefix queries. Use sqlite -database to search for the set of entries that contain the term sqlite but do not contain the term database.

Examples

String Result - Memento is the best database application on android

Search - Memento* (finds any field beginning with 'Memento')

Search - best application (finds fields containing both 'best' and 'application' within the field)

Searching libraries using barcodes

To enable scanning of barcodes:

Install “Barcode Scanner” by ZXing Team (also available to download through Memento interface).

Set up a field with the Barcode field type.

When the above criteria have been met, open the context menu > Barcode search; then scan the barcode.

jennifer gtz

unread,
Apr 17, 2017, 12:42:10 AM4/17/17
to mementodatabase
Pedro, did you ever find out more information on the syntax of find(query)? 
I am also looking for information on this function to us to return a list of records that contain the current record's name in a field. 

Bill Crews

unread,
Apr 17, 2017, 10:03:24 AM4/17/17
to mementodatabase
In the Memento JavaScript Library wiki page, it says "This search is similar to searching via Memento's user interface."

So, I opened the Library List screen wiki page and was surprised to find that it does not have a section about the magnifying glass on that screen. I'll fix that.

In the meantime, if you go to the bottom of the main page of the wiki and tap on FAQ, you'll see the following language:

Can I search using wildcards?

Yes, wildcards can be used for partial word searching. By using the asterisk symbol ( * ), you can generate a wildcard search and find specific words throughout a record.

Here are some examples:
String Result: Memento is the best database application on android
Search: Memento* (finds any field beginning with 'Memento')
Search: *database* (finds 'database' throughout the field)
Search: *best* *application* (finds fields containing both 'best' and 'application' within the field)

Can I search libraries using barcodes?

Yes, before you can scan barcodes, you must first:
Install “Barcode Scanner” by ZXing Team (also available to download through Memento interface).
Set up a field with the Barcode field type

When the above criteria have been filled, open the context menu > Barcode search';' then scan the barcode.

Maybe that will help.

jennifer gtz

unread,
Apr 17, 2017, 10:56:21 AM4/17/17
to mementodatabase
Thank you Bill, but I am not actually talking about using the existing search via the memento's user interface.  Based on the Memento JavaScript Library page on the wiki, I would like to use the Library Method, find(query), to find all the records that have a certain name in a field on their record and list them on that certain name's record in a field.  Not within the search functionality.  I I would prefer to mot have to go out of a record to see who are this dad's children. 

Bill Crews

unread,
Apr 17, 2017, 11:09:42 AM4/17/17
to mementodatabase
I understand that. But, nevertheless, the FAQ says "This search is similar to searching via Memento's user interface."

Maybe I'm being presumptuous, but I presume that what he means by this is that, if you use the same query string for find() that you would've entered into the UI Search field, you'll get the same results.

Bill Crews

unread,
Apr 17, 2017, 11:18:28 AM4/17/17
to mementodatabase
By the way, I'm preparing to release a JavaScript library for use with Memento, and the first function in there will be a search function with better search flexibility. I expect to release it in early May. You'll need 4.3.x to use it, though.
Message has been deleted
Message has been deleted

Alan Wehmann

unread,
May 3, 2017, 10:51:40 PM5/3/17
to mementodatabase
I posted here earlier saying that I couldn't get "find" to work.  I've now figured out my misunderstanding.  I've deleted that post and now substitute this one.  I was confusing "search" and "filter".  As Bill Crews pointed out, a "search" is done on the Entries List screen page.  I'll describe a couple of test libraries that I was using and show my initial Action script that didn't work and then the Action script that does work.

I have one library ("Walkaround Copy") where I inserted my test Action script. It has three text fields: unit, address, name.  The structure of this library doesn't matter & it only serves as a place to put the Action script and run it.  My second library is named "Addresses Copy" and has three text fields: Unit, Address, Name.  It has one entry, with values 5804,3333,Fred.

The Action script that didn't work is shown below.  It's "find" query was inspired by what a filter looks like.

var lib1 = libByName("Addresses Copy");
lib1.show();
var search1 = lib1.find("Unit is equal to 5804");
message(search1.length);

When I execute this script, the message was "0".  That means that there were zero entries found.

Between this script and the one that did work, I played with search strings as described by Bill Crews, using the "Addresses Copy" library.  String "5804" was enough to find my one entry.  I could also use "3333" or "Fred".

The test Action script that works (inside Library "Walkaround Copy") is the following:

var lib1 = libByName("Addresses Copy");
//lib1.show();
//message(lib1.entries().length);
var search1 = lib1.find("5804");
message(search1.length);
message(search1[0].field("address"));

Alan Wehmann

unread,
May 4, 2017, 2:33:42 PM5/4/17
to mementodatabase
It seems to me that "search" should appear explicitly in the Wiki index.  As a new user I overlooked "search" for a while.  Now that I am aware of it, its capabilities completely change my plan for how I will use two linked libraries.  To be explicit, I'm referring to the "search" description at "http://wiki.mementodatabase.com/index.php/Library_Entries_List_screen#Search".
Reply all
Reply to author
Forward
0 new messages