GithubHelp home page GithubHelp logo

Comments (1)

khalidsalomao avatar khalidsalomao commented on July 23, 2024

Hi @LeMoussel,

The recommended way is to use the same key used to store the item, since it will use a database index (best performance).

So, if you have a key that was used to store the inserted row, you can pass it as the first parameter:

// save an item with a key associated
db.Set ("my_key_for_this_item", new MyExampleClass ());

// remove it
db.FindAndRemove ("my_key_for_this_item", null);

Usually I recommend to store the key with the object, to make things easier!

Example:

var row = new MyExampleRow ();
row.Id = "my_key_for_this_item";

// save an item with a key associated
db.Set (row.Id, row);

// remove it
db.FindAndRemove (row.Id, null);

There are other uses, but uses the LIKE sql expression to remove rows. This is slow, since is not using an index, and may have undesirable consequences, so only use it if you know what is happening behind the scenes!

Example:

var user = new MyExampleUser ();
row.Id = "my_key_for_this_item";
row.Name = "my name";
row.Password = "*******";

// save an item with a key associated
db.Set (row.Id, row);

// remove it by name
db.FindAndRemove (null, new { Name = "my name" });

// OR remove it by key and name
db.FindAndRemove ("my_key_for_this_item", new { Name = "my name" });

from simplehelpers.net.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.